Main Content

Set Up a PowerPoint Presentation Template

A PowerPoint® template specifies the fixed content and default layout and appearance of the slides in a presentation. When you create a presentation by using the PPT API, you can specify a template to use. The template can be empty or have slides. Any content in the template appears in the new presentation. If you do not specify a template, the PPT API uses a default template.

The template that you specify can be:

  • A customized copy of the PPT API default template.

  • An existing presentation.

  • A template that you set up in PowerPoint.

To customize a copy of the default template or an existing presentation that you want to use as a template, you can use the PPT API or PowerPoint. To add or customize slide layouts, use PowerPoint.

Specify a Template

To specify a template, provide the template name as the second argument when you create an mlreportgen.ppt.Presentation object. For example, this code specifies the template myTemplate.pptx.

import mlreportgen.ppt.*

ppt = Presentation("myPresentation.pptx","myTemplate.pptx");

To use the PPT API default template, omit the second argument. For example:

import mlreportgen.ppt.*

ppt = Presentation("myPresentation.pptx");

Copy the Default Template

To copy the PPT API default template, use mlreportgen.ppt.Presentation.createTemplate. For example:

templatePath = mlreportgen.ppt.Presentation.createTemplate("myTemplate.pptx");

Customize a Template Using the PPT API

To customize a copy of the default PPT API template or an existing presentation that you want to use as a template:

  1. Create a Presentation object and specify the template for both the presentation argument and the template argument.

  2. Update the template so that it contains the slides and content that you want in the template. For example, add a slide.

  3. To save the template, close the Presentation object.

For example, this code creates a copy of the default template, adds a title slide to the template, replaces the slide title, and specifies that the title is red:

mlreportgen.ppt.Presentation.createTemplate(templateName);
import mlreportgen.ppt.*

templateName = "myTemplate.pptx";
ppt1 = Presentation(templateName,templateName);
open(ppt1);
slide = add(ppt1,"Title Slide");
title = Paragraph("My Title");
title.Style = [title.Style {FontColor("red")}];
replace(slide,"Title",title);
close(ppt1);
rptview(ppt1);

When you create a presentation using myTemplate.pptx as the template, the presentation has a title slide with the title My Title in red.

To customize an existing presentation that you want to use a template, use the same procedure that you use to customize a copy of the default template. For example, this code creates a presentation called myPresentation.pptx that has one slide and then customizes myPresentation.pptx by replacing the slide title and making the title text red.

import mlreportgen.ppt.*

presName = "myPresentation.pptx";
ppt2 = Presentation(presName);
open(ppt2);
slide = add(ppt2,"Title Slide");
close(ppt2);

ppt3 = Presentation(presName,presName);
open(ppt3);
slide = ppt3.Children(1);
title = Paragraph("My Title");
title.Style = [title.Style {FontColor("red")}];
replace(slide,"Title",title);
close(ppt3);
rptview(ppt3);

When you create a presentation using myPresentation.pptx as the template, the presentation has a title slide with a title My Title in red.

Customize a Template Interactively in PowerPoint

Use PowerPoint for these template customizations:

Specify the Default Formatting of a Presentation

To specify formatting to apply throughout a presentation, use a slide master. The formatting in a slide master is the default formatting for all its child slide layouts.

  1. In PowerPoint, open a template or a presentation that you want to use as a template.

  2. In the View tab, in the Master Views section, click Slide Master. For example, using the default PPT API template:

    PowerPoint Slide Master view

  3. In a slide master, click in a placeholder. For example, in the master title slide, click in Click to edit Master title style text and select a formatting option, such as changing the font color to red.

  4. Save the template.

Add a Slide Master

You can add a slide master to a PowerPoint template. Adding a slide master is useful for providing different formatting for different parts of a presentation.

  1. Open the template in PowerPoint.

  2. In the View tab, in the Master Views section, click Slide Master.

  3. In the slide master and layout pane, click after the last slide layout.

  4. Right-click and select Insert Slide Master. A new slide master appears, with a copy of the slide layouts under it.

    Slide master and layout pane with new master slide

  5. Format the new slide master.

  6. Give the slide master a meaningful name. By default, PowerPoint names new masters Custom Design, 1_Custom Design, 2_Custom Design, and so on. In the Slide Master tab, in the Edit Master section, click Rename and follow the prompts.

  7. Save the template.

Format a Slide Layout

To specify formatting to apply to a specific kind of slide, use a slide layout.

  1. Open the template in PowerPoint.

  2. In the View tab, in the Master Views section, click Slide Master.

  3. From the slide masters and layout pane, select the slide layout whose formatting you want to change. For example, in the PPT API default template, click the Title and Content slide layout.

    Tip

    To see the name of a slide layout, point to the layout. A tooltip appears with the name of the slide layout and the number of slides that use the layout.

    Slide master view with Title and Content slide layout selected

  4. In a slide master, click in a placeholder whose formatting you want to change. For example, in the default PPT API template, in the Title and Content slide layout, click in Click to edit Master title style. Select a formatting option, such as changing the font color to red. The change applies to the title of that slide layout, but not to the title of other slide layouts.

    Placeholder title in the Title and Content slide layout is red.

  5. Save the template.

Add a Slide Layout

You can add a slide layout to a PowerPoint template.

  1. Open the template in PowerPoint.

  2. In the View tab, in the Master Views section, click Slide Master.

  3. In a slide layout, right-click and select Insert Layout. A new slide layout appears, with a title placeholder.

    Tip

    To create a slide layout based on an existing slide layout, right-click in the slide layout that you want to base the layout on. Then select Duplicate Layout.

  4. Customize the layout. For example, you can change the font for an existing placeholder or add a placeholder, such as a table placeholder. You can interactively set the location and size of the table placeholder. To remove or add title and footers, use the Title and Footers check boxes in the Slide Master tab.

    Slide Master view with Insert Placeholder > Table selected

  5. Give the slide layout a meaningful name. (By default PowerPoint names new layouts Custom Layout, 1_Custom Layout, 2_Custom Layout, and so on.) In the Slide Master tab, in the Edit Master section, click Rename and follow the prompts.

  6. Save the template.

Add a Placeholder to a Slide Layout

You can add any type of placeholder to any slide layout. However, using the PPT API, you can replace this subset of placeholders:

  • Content

  • Text

  • Picture

  • Table

  1. Open the template in PowerPoint.

  2. In the View tab, in the Master Views section, click Slide Master.

  3. In the slide layout pane, select the slide layout to which you wan to add the placeholder.

  4. In the Slide Master tab, in the Master Layout section, click Insert Placeholder and select the type of placeholder from the list. For example, in the default PPT API template, add a Table placeholder to the Blank slide layout.

    Slide Master view with Insert Placeholder > Table selected

  5. In the slide layout, size and position the placeholder.

  6. Name the placeholders that you want to use when you add or replace content with the PPT API. To name a placeholder, first display the Selection pane. On the Home tab, in the Editing section, select Select > Selection Pane. In the Selection pane, click the placeholder name and type a new one.

  7. Save the template.

Related Topics