Compartilhar via


PowerPoint.ShapeCollection class

Representa a coleção de formas.

Extends

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml

// Changes the transparency of every geometric shape in the slide.
await PowerPoint.run(async (context) => {
  // Get the type of shape for every shape in the collection.
  const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
  shapes.load("type");
  await context.sync();

  // Change the shape transparency to be halfway transparent.
  shapes.items.forEach((shape) => {
    if (shape.type === PowerPoint.ShapeType.geometricShape) {
      shape.fill.transparency = 0.5;
    }
  });
  await context.sync();
});

Propriedades

context

O contexto do pedido associado ao objeto . Esta ação liga o processo do suplemento ao processo da aplicação anfitriã do Office.

items

Obtém os itens filhos carregados nesta coleção.

Métodos

addGeometricShape(geometricShapeType, options)

Adiciona uma forma geométrica ao diapositivo. Devolve um Shape objeto que representa a nova forma.

addGeometricShape(geometricShapeTypeString, options)

Adiciona uma forma geométrica ao diapositivo. Devolve um Shape objeto que representa a nova forma.

addGroup(values)

Crie um grupo de formas para várias formas.

addLine(connectorType, options)

Adiciona uma linha ao diapositivo. Devolve um Shape objeto que representa a nova linha.

addLine(connectorTypeString, options)

Adiciona uma linha ao diapositivo. Devolve um Shape objeto que representa a nova linha.

addTable(rowCount, columnCount, options)

Adiciona uma tabela ao diapositivo. Devolve um Shape objeto que representa a nova tabela. Utilize a Shape.table propriedade para obter o Table objeto para a forma.

addTextBox(text, options)

Adiciona uma caixa de texto ao diapositivo com o texto fornecido como conteúdo. Devolve um Shape objeto que representa a nova caixa de texto.

getCount()

Obtém o número de formas na coleção.

getItem(key)

Obtém uma forma com o respetivo ID exclusivo. É apresentado um erro se a forma não existir.

getItemAt(index)

Obtém uma forma com o respetivo índice baseado em zero na coleção. É gerado um erro se o índice estiver fora do intervalo.

getItemOrNullObject(id)

Obtém uma forma com o respetivo ID exclusivo. Se tal forma não existir, é devolvido um objeto com uma isNullObject propriedade definida como true. Para obter mais informações, veja *OrNullObject methods and properties (Métodos e propriedades do OrNullObject).

load(options)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNames)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNamesAndPaths)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

toJSON()

Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é transmitido para JSON.stringify(). (JSON.stringifypor sua vez, chama o toJSON método do objeto que lhe é transmitido.) Enquanto o objeto original PowerPoint.ShapeCollection é um objeto de API, o toJSON método devolve um objeto JavaScript simples (escrito como PowerPoint.Interfaces.ShapeCollectionData) que contém uma matriz de "itens" com cópias rasas de quaisquer propriedades carregadas dos itens da coleção.

Detalhes da propriedade

context

O contexto do pedido associado ao objeto . Esta ação liga o processo do suplemento ao processo da aplicação anfitriã do Office.

context: RequestContext;

Valor da propriedade

items

Obtém os itens filhos carregados nesta coleção.

readonly items: PowerPoint.Shape[];

Valor da propriedade

Detalhes do método

addGeometricShape(geometricShapeType, options)

Adiciona uma forma geométrica ao diapositivo. Devolve um Shape objeto que representa a nova forma.

addGeometricShape(geometricShapeType: PowerPoint.GeometricShapeType, options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

geometricShapeType
PowerPoint.GeometricShapeType

Especifica o tipo da forma geométrica. Veja PowerPoint.GeometricShapeType para obter detalhes.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição da forma.

Retornos

A forma recentemente inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml

// This function gets the collection of shapes on the first slide,
// and adds a hexagon shape to the collection, while specifying its
// location and size. Then it names the shape.
await PowerPoint.run(async (context) => {
  const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
  const shapeOptions: PowerPoint.ShapeAddOptions = {
    left: 100,
    top: 100,
    height: 150,
    width: 150
  };
  const hexagon: PowerPoint.Shape = shapes.addGeometricShape(PowerPoint.GeometricShapeType.hexagon, shapeOptions);
  hexagon.name = "Hexagon";

  await context.sync();
});

addGeometricShape(geometricShapeTypeString, options)

Adiciona uma forma geométrica ao diapositivo. Devolve um Shape objeto que representa a nova forma.

addGeometricShape(geometricShapeTypeString: "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus", options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

geometricShapeTypeString

"LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus"

Especifica o tipo da forma geométrica. Veja PowerPoint.GeometricShapeType para obter detalhes.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição da forma.

Retornos

A forma recentemente inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

addGroup(values)

Crie um grupo de formas para várias formas.

addGroup(values: Array<string | Shape>): PowerPoint.Shape;

Parâmetros

values

Array<string | PowerPoint.Shape>

Uma matriz de IDs ou Shape objetos de forma.

Retornos

Um Shape objeto que representa o grupo de formas. Utilize a Shape.group propriedade para aceder ao ShapeGroup objeto do grupo.

Comentários

[ Conjunto de API: PowerPointApi 1.8 ]

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/group-ungroup-shapes.yaml

await PowerPoint.run(async (context) => {
  // Groups the geometric shapes on the current slide.

  // Get the shapes on the current slide.
  context.presentation.load("slides");
  const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);
  slide.load("shapes/items/type,shapes/items/id");
  await context.sync();

  const shapes: PowerPoint.ShapeCollection = slide.shapes;
  const shapesToGroup = shapes.items.filter((item) => item.type === PowerPoint.ShapeType.geometricShape);
  if (shapesToGroup.length === 0) {
    console.warn("No shapes on the current slide, so nothing to group.");
    return;
  }

  // Group the geometric shapes.
  console.log(`Number of shapes to group: ${shapesToGroup.length}`);
  const group = shapes.addGroup(shapesToGroup);
  group.load("id");
  await context.sync();

  console.log(`Grouped shapes. Group ID: ${group.id}`);
});

addLine(connectorType, options)

Adiciona uma linha ao diapositivo. Devolve um Shape objeto que representa a nova linha.

addLine(connectorType?: PowerPoint.ConnectorType, options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

connectorType
PowerPoint.ConnectorType

Especifica o tipo de conexão da linha. Se não for fornecido, straight será utilizado o tipo de conector. Consulte PowerPoint.ConnectorType para obter detalhes.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição do objeto de forma que contém a linha.

Retornos

A forma recentemente inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml

// This function gets the collection of shapes on the first slide,
// and adds a line to the collection, while specifying its
// start and end points. Then it names the shape.
await PowerPoint.run(async (context) => {
  const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;

  // For a line, left and top are the coordinates of the start point,
  // while height and width are the coordinates of the end point.
  const line: PowerPoint.Shape = shapes.addLine(PowerPoint.ConnectorType.straight, 
      { 
        left: 400, 
        top: 200, 
        height: 20, 
        width: 150 
      });
  line.name = "StraightLine";

  await context.sync();
});

addLine(connectorTypeString, options)

Adiciona uma linha ao diapositivo. Devolve um Shape objeto que representa a nova linha.

addLine(connectorTypeString?: "Straight" | "Elbow" | "Curve", options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

connectorTypeString

"Straight" | "Elbow" | "Curve"

Especifica o tipo de conexão da linha. Se não for fornecido, straight será utilizado o tipo de conector. Consulte PowerPoint.ConnectorType para obter detalhes.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição do objeto de forma que contém a linha.

Retornos

A forma recentemente inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

addTable(rowCount, columnCount, options)

Adiciona uma tabela ao diapositivo. Devolve um Shape objeto que representa a nova tabela. Utilize a Shape.table propriedade para obter o Table objeto para a forma.

addTable(rowCount: number, columnCount: number, options?: PowerPoint.TableAddOptions): PowerPoint.Shape;

Parâmetros

rowCount

number

Número de linhas na tabela. Tem de ser 1 ou superior.

columnCount

number

Número de colunas na tabela. Tem de ser 1 ou superior.

options
PowerPoint.TableAddOptions

Fornece opções que descrevem a nova tabela.

Retornos

A forma recentemente inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.8 ]

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Adds a basic table.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Add a simple table, specifying the row and column count.
  shapes.addTable(3, 4);
  await context.sync();
});

addTextBox(text, options)

Adiciona uma caixa de texto ao diapositivo com o texto fornecido como conteúdo. Devolve um Shape objeto que representa a nova caixa de texto.

addTextBox(text: string, options?: PowerPoint.ShapeAddOptions): PowerPoint.Shape;

Parâmetros

text

string

Especifica o texto que será apresentado na caixa de texto criada.

options
PowerPoint.ShapeAddOptions

Um parâmetro opcional para especificar as opções adicionais, como a posição da caixa de texto.

Retornos

A forma recentemente inserida.

Comentários

[ Conjunto de API: PowerPointApi 1.4 ]

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/shapes.yaml

// This function gets the collection of shapes on the first slide,
// and adds a text box to the collection, while specifying its text,
// location, and size. Then it names the text box.
await PowerPoint.run(async (context) => {
  const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
  const textbox: PowerPoint.Shape = shapes.addTextBox("Hello!", 
      { 
        left: 100, 
        top: 300, 
        height: 300, 
        width: 450 
      });
  textbox.name = "Textbox";

  return context.sync();
});

getCount()

Obtém o número de formas na coleção.

getCount(): OfficeExtension.ClientResult<number>;

Retornos

O número de formas na coleção.

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/add-modify-tables.yaml

// Gets the table from a shape.
await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();

  if (shapeCount.value > 0) {
    const shape = shapes.getItemAt(0);
    shape.load("type");
    await context.sync();

    // The shape type can indicate whether the shape is a table.
    const isTable = shape.type === PowerPoint.ShapeType.table;

    if (isTable) {
      // Get the Table object for the Shape which is a table.
      const table = shape.getTable();
      table.load();
      await context.sync();

      // Get the Table row and column count.
      console.log("Table RowCount: " + table.rowCount + " and columnCount: " + table.columnCount);
    } else console.log("Selected shape isn't table.");
  } else console.log("No shape selected.");
});

getItem(key)

Obtém uma forma com o respetivo ID exclusivo. É apresentado um erro se a forma não existir.

getItem(key: string): PowerPoint.Shape;

Parâmetros

key

string

O ID da forma.

Retornos

A forma com o ID exclusivo. Se tal forma não existir, é gerado um erro.

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

getItemAt(index)

Obtém uma forma com o respetivo índice baseado em zero na coleção. É gerado um erro se o índice estiver fora do intervalo.

getItemAt(index: number): PowerPoint.Shape;

Parâmetros

index

number

O índice da forma na coleção.

Retornos

A forma no índice especificado. É apresentado um erro se o índice estiver fora do intervalo.

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/tags/tags.yaml

await PowerPoint.run(async function(context) {
  const slide: PowerPoint.Slide = context.presentation.slides.getItemAt(0);
  const shape: PowerPoint.Shape = slide.shapes.getItemAt(0);
  shape.tags.add("MOUNTAIN", "Denali");

  await context.sync();

  const myShapeTag: PowerPoint.Tag = shape.tags.getItem("MOUNTAIN");
  myShapeTag.load("key, value");

  await context.sync();

  console.log("Added key " + JSON.stringify(myShapeTag.key) + " with value " + JSON.stringify(myShapeTag.value));
});

getItemOrNullObject(id)

Obtém uma forma com o respetivo ID exclusivo. Se tal forma não existir, é devolvido um objeto com uma isNullObject propriedade definida como true. Para obter mais informações, veja *OrNullObject methods and properties (Métodos e propriedades do OrNullObject).

getItemOrNullObject(id: string): PowerPoint.Shape;

Parâmetros

id

string

O ID da forma.

Retornos

A forma com o ID exclusivo. Se tal forma não existir, é devolvido um objeto com uma isNullObject propriedade definida como true.

Comentários

[ Conjunto de API: PowerPointApi 1.3 ]

load(options)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(options?: PowerPoint.Interfaces.ShapeCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions): PowerPoint.ShapeCollection;

Parâmetros

options

PowerPoint.Interfaces.ShapeCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions

Fornece opções para as propriedades do objeto a carregar.

Retornos

load(propertyNames)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNames?: string | string[]): PowerPoint.ShapeCollection;

Parâmetros

propertyNames

string | string[]

Uma cadeia delimitada por vírgulas ou uma matriz de cadeias que especificam as propriedades a carregar.

Retornos

Exemplos

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shapes-by-type.yaml

// Changes the transparency of every geometric shape in the slide.
await PowerPoint.run(async (context) => {
  // Get the type of shape for every shape in the collection.
  const shapes: PowerPoint.ShapeCollection = context.presentation.slides.getItemAt(0).shapes;
  shapes.load("type");
  await context.sync();

  // Change the shape transparency to be halfway transparent.
  shapes.items.forEach((shape) => {
    if (shape.type === PowerPoint.ShapeType.geometricShape) {
      shape.fill.transparency = 0.5;
    }
  });
  await context.sync();
});

load(propertyNamesAndPaths)

Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.

load(propertyNamesAndPaths?: OfficeExtension.LoadOption): PowerPoint.ShapeCollection;

Parâmetros

propertyNamesAndPaths
OfficeExtension.LoadOption

propertyNamesAndPaths.select é uma cadeia delimitada por vírgulas que especifica as propriedades a carregar e propertyNamesAndPaths.expand é uma cadeia delimitada por vírgulas que especifica as propriedades de navegação a carregar.

Retornos

toJSON()

Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é transmitido para JSON.stringify(). (JSON.stringifypor sua vez, chama o toJSON método do objeto que lhe é transmitido.) Enquanto o objeto original PowerPoint.ShapeCollection é um objeto de API, o toJSON método devolve um objeto JavaScript simples (escrito como PowerPoint.Interfaces.ShapeCollectionData) que contém uma matriz de "itens" com cópias rasas de quaisquer propriedades carregadas dos itens da coleção.

toJSON(): PowerPoint.Interfaces.ShapeCollectionData;

Retornos