Main Content

add

Class: mlreportgen.ppt.Presentation
Namespace: mlreportgen.ppt

Add slide to presentation

Description

slideObj = add(presentation,slideLayout) adds a slide to the presentation using the specified slide layout name. If the specified layout occurs in multiple slide masters, the PPT API uses the first occurrence of the layout that it finds in the template.

example

slideObj = add(presentation,slideLayout,slideMaster) uses the specified slide layout in the specified slide master. Use the slideMaster argument when the specified layout occurs in multiple slide masters.

slideObj = add(presentation,slideLayout,otherSlide) adds the slide immediately before the slide specified in the otherSlide argument, using the specified slide layout in the first slide master in the presentation.

slideObj = add(presentation,slideLayout,slideMaster,otherSlide) adds the slide immediately before the otherSlide slide, using the specified slide layout in the specified slide master.

example

slideObj = add(presentation,slideLayout,index) adds the slide at the index position specified by index, using the specified slide layout in the first slide master in the presentation.

slideObj = add(presentation,slideLayout,slideMaster,index) adds the slide at the index position specified by index, using the specified slide layout in the specified slide master.

example

Examples

expand all

Import the PPT namespace so that you do not have to use long, fully qualified names for the PPT API classes.

import mlreportgen.ppt.*

Create and open a presentation named myPresentation.pptx.

ppt = Presentation('myPresentation.pptx');
open(ppt);

Add the first slide and specify the slide layout, but not the slide master or location.

contentSlide = add(ppt,'Title and Content');
replace(contentSlide,'Title','This is the Title of the Slide Content');

Add another slide using the Office Theme slide master. Insert it before the slide represented by contentSlide.

titleSlide = add(ppt,'Title Slide','Office Theme',contentSlide);
replace(titleSlide,'Title','Presentation Title');

Add a blank slide using the Office Theme slide master. Make the new slide the second slide in the presentation.

blankSlide = add(ppt,'Blank','Office Theme',2);

Close and view the presentation.

close(ppt);
rptview(ppt);

Here is the generated presentation:

Input Arguments

expand all

Presentation to add content to, specified as an mlreportgen.ppt.Presentation object.

Layout of slide to add, specified as a character vector or string scalar. The layout must be in the presentation template.

To see the available layouts, you can:

  • Use the getLayoutNames method.

  • In the PowerPoint® template, on the Home tab, in the Slides section, click Layout.

Slide master for the specified slide layout, specified as a character vector or string scalar. The slide master must be in the presentation template.

To see the available slide masters, use one of these approaches:

  • Use the getMasterNames method.

  • In the PowerPoint template, on the View tab, in the Master Views section, click Slide Master. The slide masters are the numbered slides. Point to the slide master to see its name. Specify the name without including the words Slide Master.

Slide to insert new slide before, specified as an mlreportgen.ppt.Slide object.

Index position of slide in presentation, specified as an integer.

Output Arguments

expand all

Slide, returned as an mlreportgen.ppt.Slide object.

Version History

Introduced in R2015b