PowerPoint.Slide class

Represents a single slide of a presentation.

Extends

Remarks

[ API set: PowerPointApi 1.2 ]

Properties

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

id

Gets the unique ID of the slide.

layout

Gets the layout of the slide.

shapes

Returns a collection of shapes in the slide.

slideMaster

Gets the SlideMaster object that represents the slide's default content.

tags

Returns a collection of tags in the slide.

Methods

delete()

Deletes the slide from the presentation. Does nothing if the slide does not exist.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

setSelectedShapes(shapeIds)

Selects the specified shapes. Existing shape selection is replaced with the new selection.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original PowerPoint.Slide object is an API object, the toJSON method returns a plain JavaScript object (typed as PowerPoint.Interfaces.SlideData) that contains shallow copies of any loaded child properties from the original object.

Property Details

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

id

Gets the unique ID of the slide.

readonly id: string;

Property Value

string

Remarks

[ API set: PowerPointApi 1.2 ]

layout

Gets the layout of the slide.

readonly layout: PowerPoint.SlideLayout;

Property Value

Remarks

[ API set: PowerPointApi 1.3 ]

shapes

Returns a collection of shapes in the slide.

readonly shapes: PowerPoint.ShapeCollection;

Property Value

Remarks

[ API set: PowerPointApi 1.3 ]

slideMaster

Gets the SlideMaster object that represents the slide's default content.

readonly slideMaster: PowerPoint.SlideMaster;

Property Value

Remarks

[ API set: PowerPointApi 1.3 ]

tags

Returns a collection of tags in the slide.

readonly tags: PowerPoint.TagCollection;

Property Value

Remarks

[ API set: PowerPointApi 1.3 ]

Method Details

delete()

Deletes the slide from the presentation. Does nothing if the slide does not exist.

delete(): void;

Returns

void

Remarks

[ API set: PowerPointApi 1.2 ]

Examples

// 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 slides = context.presentation.slides;
  slides.load("tags/key, tags/value");

  await context.sync();

  for (let i = 0; i < slides.items.length; i++) {
    let currentSlide = slides.items[i];
    for (let j = 0; j < currentSlide.tags.items.length; j++) {
      let currentTag = currentSlide.tags.items[j];
      if (currentTag.key === "CUSTOMER_TYPE" && currentTag.value === "Premium") {
        currentSlide.delete();
      }
    }
  }

  await context.sync();
});

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: PowerPoint.Interfaces.SlideLoadOptions): PowerPoint.Slide;

Parameters

options
PowerPoint.Interfaces.SlideLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

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

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): PowerPoint.Slide;

Parameters

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

setSelectedShapes(shapeIds)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Selects the specified shapes. Existing shape selection is replaced with the new selection.

setSelectedShapes(shapeIds: string[]): void;

Parameters

shapeIds

string[]

List of shape IDs to select in the slide. If the list is empty, the selection is cleared.

Returns

void

Remarks

[ API set: PowerPointApi BETA (PREVIEW ONLY) ]

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original PowerPoint.Slide object is an API object, the toJSON method returns a plain JavaScript object (typed as PowerPoint.Interfaces.SlideData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): PowerPoint.Interfaces.SlideData;

Returns