PowerPoint.Slide class
Represents a single slide of a presentation.
- Extends
Remarks
[ API set: PowerPointApi 1.2 ]
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml
// Reselects shapes that were saved previously.
await PowerPoint.run(async (context) => {
const slide1: PowerPoint.Slide = context.presentation.slides.getItem(savedSlideSelection[0]);
await context.sync();
slide1.setSelectedShapes(savedShapeSelection);
await context.sync();
});
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. |
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 |
load(property |
Queues up a command to load the specified properties of the object. You must call |
load(property |
Queues up a command to load the specified properties of the object. You must call |
toJSON() | Overrides the JavaScript |
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
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/slide-management/get-set-slides.yaml
// Deletes the selected slides.
await PowerPoint.run(async (context) => {
context.presentation.load("slides");
await context.sync();
const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides();
const slideCount = slides.getCount();
slides.load("items");
await context.sync();
slides.items.map((slide) => {
slide.delete();
});
});
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
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
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's 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
Office Add-ins