Access PowerPoint Template Elements
PPT API Applications and PowerPoint Templates
The PPT API uses PowerPoint® presentations as templates to generate presentations. Templates allow you to specify the fixed content and default layout and appearance of the slides in your presentations. Your MATLAB® program can use the PPT API to override the default layout and format of specific slides.
The template can be an empty presentation or a presentation with slides. You can use the following as templates for a PPT API presentation:
The default PPT API PowerPoint template
A customized copy of the default PPT API PowerPoint template
An existing PowerPoint presentation whose content you want to update
A PowerPoint template that you create or update interactively in PowerPoint
Template Elements
PowerPoint templates include several elements that the PPT API uses to generate a presentation. To customize formatting defined in a template, modify one or more of these template elements.
PowerPoint Template Element | Purpose |
---|---|
Slide masters | Applies the slide master formatting globally to the presentation. Specifies a layout and formats common to a set of slide layouts |
Slide layouts | Specifies a variant of a slide master layout. |
Table styles | Specifies the default appearance of a table. PowerPoint defines a standard set of table styles. You cannot modify these styles but you can use the PPT API to apply these styles to tables you create and override the styles for particular tables. |
Placeholders | Specifies an area of a slide layout that you can replace with text, a list, picture, table, or other content. Every placeholder has a name. You can use PowerPoint interactively to assign a name to a placeholder. You can then use the name in your PPT program to replace the placeholder with content. |
View and Change Slide Master Names
A PowerPoint template can have more than one slide master. A slide master can have a child slide layout that has the same name as a child slide layout in another slide master. When you use the PPT API, if the template has multiple slide masters, you need to know the name of the slide master so that you can specify the correct slide layout. You can find out the name in PowerPoint or using the API.
You can rename a master to identify its purpose. You can rename a slide master only in PowerPoint.
In PowerPoint, select View > Slide Master.
In the slide layout pane, hover over the slide master. Slide masters are numbered and at the top level in the tree hierarchy. A tooltip displays the name. In this figure,
Office Theme
is the name to use in the API. Do not include the textSlide Master
.If you want to rename the master, from the Slide Master tab, in the Edit Master section, click Rename and follow the prompts.
To see slide master names using the PPT API, use the getMasterNames
method with an mlreportgen.ppt.Presentation
object. This example uses the default PPT API PowerPoint template, which has one slide master.
import mlreportgen.ppt.*; slides = Presentation('myPresentation'); getMasterNames(slides);
ans = 'Office Theme'
View and Change Slide Layout Names
You need to know the name of slide layouts in a PowerPoint template to add a slide using the PPT API. You can find out the slide layout name in PowerPoint and using the API.
When you add a slide layout, you can rename it to identify its purpose. You can rename a slide layout only in PowerPoint.
In PowerPoint, select View > Slide Master.
In the slide layout pane, hover over a slide layout under a slide master. A tooltip displays the name of the slide layout. In this figure,
Title Slide
is the name to use in the API. Do not include the textLayout
.If you want to rename the slide layout, from the Slide Master tab, in the Edit Master section, click Rename and follow the prompts.
To see slide layout names using the PPT API, use the Presentation.getLayoutNames
method. You need to get the slide master name before you get the layout names. The PPT API returns slide masters as a cell array. This example uses the default PPT API PowerPoint template to get the slide layouts from the first master in the template.
import mlreportgen.ppt.*; slides = Presentation('myPresentation'); masters = getMasterNames(slides); layouts = getLayoutNames(slides,masters{1}); layouts
Columns 1 through 5 'Title Slide' 'Title and Vertica…' 'Vertical Title an…' 'Title and Table' 'Title and Picture' Columns 6 through 11 'Title and Content' 'Section Header' 'Two Content' 'Comparison' 'Title Only' 'Blank' Columns 12 through 13 'Content with Capt…' 'Picture with Capt…'
View and Change Placeholder and Content Object Names
You need to know placeholder names to use the PPT API to replace placeholders with content. You can find out a placeholder name using PowerPoint or using the PPT API.
You can rename a placeholder to identify its purpose.
In PowerPoint, select View > Slide Master.
In the Home tab, in the Editing section, select Select > Selection Pane.
In the slide layout pane, select the layout that contains the content placeholder whose name you want to see. The names of the placeholders used in the slide layout appear in the Selection pane. Click in a content placeholder to highlight the name in the selection pane.
The figure shows that the name of the content placeholder in the Title and Content slide layout is
Content
.If you want to rename the placeholder, click the name in the Selection pane and type a new one.
If you update content in a PowerPoint presentation, to see the name of content objects on that slide, also use the Selection Pane. For example:
Create and generate a presentation with a slide that has a table.
import mlreportgen.ppt.* ppt = Presentation("myTablePresentation.pptx"); open(ppt); slide1 = add(ppt,'Blank'); add(slide1,Table(magic(5))); close(ppt); rptview(ppt);
In PowerPoint, display the Selection pane. The name of the table is a generated string of characters. You can rename it and use the new name with the PPT API.