Edit

Share via


PowerPoint.AddSlideOptions interface

Represents the available options when adding a new slide.

Remarks

[ API set: PowerPointApi 1.3 ]

Examples

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

const chosenMaster = (document.getElementById("master-id") as HTMLInputElement).value;
const chosenLayout = (document.getElementById("layout-id") as HTMLInputElement).value;

await PowerPoint.run(async function(context) {
  // Create a new slide using an existing master slide and layout.
  const newSlideOptions: PowerPoint.AddSlideOptions = {
    slideMasterId: chosenMaster, /* An ID from `Presentation.slideMasters`. */
    layoutId: chosenLayout /* An ID from `SlideMaster.layouts`. */
  };
  context.presentation.slides.add(newSlideOptions);
  await context.sync();
});

Properties

index

Specifies the 0-based index at which the new slide should be inserted. If not specified or if the specified index is out of bounds, the new slide will be added at the end of the presentation.

layoutId

Specifies the ID of a Slide Layout to be used for the new slide. If no layoutId is provided, but a slideMasterId is provided, then the ID of the first layout from the specified Slide Master will be used. If no slideMasterId is provided, but a layoutId is provided, then the specified layout needs to be available for the default Slide Master (as specified in the slideMasterId description). Otherwise, an error will be thrown.

slideMasterId

Specifies the ID of a Slide Master to be used for the new slide. If no slideMasterId is provided, then the previous slide's Slide Master will be used. If there is no previous slide, then the presentation's first Slide Master will be used.

Property Details

index

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.

Specifies the 0-based index at which the new slide should be inserted. If not specified or if the specified index is out of bounds, the new slide will be added at the end of the presentation.

index?: number;

Property Value

number

Remarks

[ API set: PowerPointApi BETA (PREVIEW ONLY) ]

layoutId

Specifies the ID of a Slide Layout to be used for the new slide. If no layoutId is provided, but a slideMasterId is provided, then the ID of the first layout from the specified Slide Master will be used. If no slideMasterId is provided, but a layoutId is provided, then the specified layout needs to be available for the default Slide Master (as specified in the slideMasterId description). Otherwise, an error will be thrown.

layoutId?: string;

Property Value

string

Remarks

[ API set: PowerPointApi 1.3 ]

slideMasterId

Specifies the ID of a Slide Master to be used for the new slide. If no slideMasterId is provided, then the previous slide's Slide Master will be used. If there is no previous slide, then the presentation's first Slide Master will be used.

slideMasterId?: string;

Property Value

string

Remarks

[ API set: PowerPointApi 1.3 ]