PowerPoint.ShapeCollection class

Representa a coleção de formas.

Extends

Comentários

Conjunto de APIs: PowerPointApi 1.3

Usada por

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 de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office.

items

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

Métodos

addGeometricShape(geometricShapeType, options)

Adiciona uma forma geométrica ao slide. Retorna um Shape objeto que representa a nova forma.

addGeometricShape(geometricShapeType, options)

Adiciona uma forma geométrica ao slide. Retorna 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 slide. Retorna um Shape objeto que representa a nova linha.

addLine(connectorType, options)

Adiciona uma linha ao slide. Retorna um Shape objeto que representa a nova linha.

addPicture(base64EncodedImage, options)

Adiciona uma imagem ao slide. Retorna um Shape objeto que representa a nova imagem.

addTable(rowCount, columnCount, options)

Adiciona uma tabela ao slide. Retorna um Shape objeto que representa a nova tabela. Use a Shape.table propriedade para obter o Table objeto para a forma.

addTextBox(text, options)

Adiciona uma caixa de texto ao slide com o texto fornecido como conteúdo. Retorna 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 usando sua ID exclusiva. Um erro será gerado se a forma não existir.

getItemAt(index)

Obtém uma forma usando seu índice baseado em zero na coleção. Um erro será gerado se o índice estiver fora do intervalo.

getItemOrNullObject(id)

Obtém uma forma usando sua ID exclusiva. Se tal forma não existir, um objeto com uma isNullObject propriedade definida como true será retornado. Para obter mais informações, consulte métodos e propriedades *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 é passado para JSON.stringify(). (JSON.stringify, por sua vez, chama o toJSON método do objeto que é passado para ele.) Enquanto o objeto original PowerPoint.ShapeCollection é um objeto API, o toJSON método retorna um objeto JavaScript simples (digitado como PowerPoint.Interfaces.ShapeCollectionData) que contém uma matriz "items" com cópias superficiais de todas as propriedades carregadas dos itens da coleção.

Detalhes da propriedade

context

O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host 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 slide. Retorna 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. Consulte 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 recém-inserida.

Comentários

Conjunto de APIs: 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(geometricShapeType, options)

Adiciona uma forma geométrica ao slide. Retorna um Shape objeto que representa a nova forma.

addGeometricShape(geometricShapeType: "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

geometricShapeType

"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. Consulte 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 recém-inserida.

Comentários

Conjunto de APIs: 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 objetos ou Shape IDs de forma.

Retornos

Um Shape objeto que representa o grupo de formas. Use a Shape.group propriedade para acessar o ShapeGroup objeto do grupo.

Comentários

Conjunto de APIs: 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 slide. Retorna 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 conector da linha. Se não for fornecido, o tipo de straight conector será usado. 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 recém-inserida.

Comentários

Conjunto de APIs: 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(connectorType, options)

Adiciona uma linha ao slide. Retorna um Shape objeto que representa a nova linha.

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

Parâmetros

connectorType

"Straight" | "Elbow" | "Curve"

Especifica o tipo de conector da linha. Se não for fornecido, o tipo de straight conector será usado. 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 recém-inserida.

Comentários

Conjunto de APIs: PowerPointApi 1.4

addPicture(base64EncodedImage, options)

Observação

Esta API é fornecida como uma versão prévia para desenvolvedores e pode ser alterada com base nos comentários que recebemos. Não use esta API em um ambiente de produção.

Adiciona uma imagem ao slide. Retorna um Shape objeto que representa a nova imagem.

addPicture(base64EncodedImage: string, options?: PowerPoint.PictureAddOptions): PowerPoint.Shape;

Parâmetros

base64EncodedImage

string

Os dados de imagem codificados em base64.

options
PowerPoint.PictureAddOptions

Opcional. Opções adicionais, como a posição da imagem.

Retornos

A forma recém-inserida.

Comentários

Conjunto de APIs: PowerPointApi BETA (SOMENTE VISUALIZAÇÃO)

Exemplos

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

// Insert a picture on the current slide.
await PowerPoint.run(async (context) => {
  const slide: PowerPoint.Slide = context.presentation.getSelectedSlides().getItemAt(0);

  // Use PictureAddOptions to control the position and dimensions (in points).
  const options: PowerPoint.PictureAddOptions = {
    left: 100,
    top: 100,
    width: 250,
    height: 180,
  };

  const picture: PowerPoint.Shape = slide.shapes.addPicture(getSampleImageBase64(), options);
  picture.name = "SamplePicture";

  // Set accessibility properties on the inserted picture.
  picture.altTextTitle = "Sample image";
  picture.altTextDescription = "A cartoon dog image used as a sample picture in this add-in.";

  await context.sync();
});

addTable(rowCount, columnCount, options)

Adiciona uma tabela ao slide. Retorna um Shape objeto que representa a nova tabela. Use 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. Deve ser 1 ou maior.

columnCount

number

Número de colunas na tabela. Deve ser 1 ou maior.

options
PowerPoint.TableAddOptions

Fornece opções que descrevem a nova tabela.

Retornos

A forma recém-inserida.

Comentários

Conjunto de APIs: 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 slide com o texto fornecido como conteúdo. Retorna 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á mostrado 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 recém-inserida.

Comentários

Conjunto de APIs: 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 APIs: 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 usando sua ID exclusiva. Um erro será gerado se a forma não existir.

getItem(key: string): PowerPoint.Shape;

Parâmetros

key

string

A ID da forma.

Retornos

A forma com a ID exclusiva. Se tal forma não existir, um erro será gerado.

Comentários

Conjunto de APIs: PowerPointApi 1.3

getItemAt(index)

Obtém uma forma usando seu índice baseado em zero na coleção. Um erro será gerado 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 fornecido. Um erro será gerado se o índice estiver fora do intervalo.

Comentários

Conjunto de APIs: 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 usando sua ID exclusiva. Se tal forma não existir, um objeto com uma isNullObject propriedade definida como true será retornado. Para obter mais informações, consulte métodos e propriedades *OrNullObject.

getItemOrNullObject(id: string): PowerPoint.Shape;

Parâmetros

id

string

A ID da forma.

Retornos

A forma com a ID exclusiva. Se tal forma não existir, um objeto com uma isNullObject propriedade definida como true será retornado.

Comentários

Conjunto de APIs: 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 quais propriedades do objeto devem ser carregadas.

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 de caracteres delimitada por vírgula ou uma matriz de cadeias de caracteres que especifica as propriedades a serem carregadas.

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 de caracteres delimitada por vírgula que especifica as propriedades a serem carregadas e propertyNamesAndPaths.expand é uma cadeia de caracteres delimitada por vírgula que especifica as propriedades de navegação a serem carregadas.

Retornos

toJSON()

Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é passado para JSON.stringify(). (JSON.stringify, por sua vez, chama o toJSON método do objeto que é passado para ele.) Enquanto o objeto original PowerPoint.ShapeCollection é um objeto API, o toJSON método retorna um objeto JavaScript simples (digitado como PowerPoint.Interfaces.ShapeCollectionData) que contém uma matriz "items" com cópias superficiais de todas as propriedades carregadas dos itens da coleção.

toJSON(): PowerPoint.Interfaces.ShapeCollectionData;

Retornos