Skip to main content

AddSlide

Appends a new slide to the end of the presentation.

Syntax​

expression.AddSlide(oSlide, nIndex);

expression - A variable that represents a ApiPresentation class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
oSlideRequiredApiSlideThe slide created using the Api#CreateSlide method.
nIndexRequirednumberIndex of the slide to be added. If not specified, the slide will be added to the end of the presentation.

Returns​

This method doesn't return any data.

Example​

Add a new slide with a gradient background to a presentation.

// How do I create and add a new slide to the end of a presentation?

// Create a slide with a radial gradient fill and add it to a presentation.

const presentation = Api.GetPresentation();
const slide = Api.CreateSlide();
const gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
const gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
const fill = Api.CreateRadialGradientFill([gs1, gs2]);
slide.SetBackground(fill);
presentation.AddSlide(slide);