Main Content

mlreportgen.ppt.Presentation class

Package: mlreportgen.ppt

Create a Microsoft PowerPoint presentation container

Description

Use an object of the mlreportgen.ppt.Presentation class to create a PowerPoint® presentation container.

The mlreportgen.ppt.Presentation class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

presentationObj = mlreportgen.ppt.Presentation() creates a presentation container and sets the OutputPath property to the default full path for the output presentation file. The default path is the current folder and the default file name is untitled. The TemplatePath property is set to the full path of the default PPT API template.

example

presentationObj = mlreportgen.ppt.Presentation(outputPath) creates a presentation container with the OutputPath property set to the value of outputPath.

example

presentationObj = mlreportgen.ppt.Presentation(outputPath,templatePath) also sets the TemplatePath property to the value of templatePath. Use this syntax when you want to use a custom template.

If the outputPath and the templatePath arguments specify the same presentation, the specified presentation becomes the template for the new presentation. When the new presentation is generated, it replaces the original presentation.

Properties

expand all

Template file for this presentation, specified as a character vector or string scalar. Provide the path and file name of the template file, with or without the file name extension. The path can be relative or absolute. If you provide the file name without the path, the file must be in the current folder.

These file extensions are not supported:

  • .ppt — PowerPoint 97–2003 Presentation

  • .pot — PowerPoint 97–2003 Template

  • .pps — PowerPoint 97–2003 Show

  • .xml — PowerPoint XML Presentation

Example: "myTemplate.pptx"

Example: "C:\myTemplates\myTemplate.pptx"

Output presentation file, specified as a character vector or string scalar. Provide the path and file name of the output presentation file, with or without the file name extension. The path can be relative or absolute. If you provide the file name without the path, the file is created in the current folder.

The file can have one of these extensions:

  • .pptx — PowerPoint Presentation

  • .pptm — PowerPoint Macro-Enabled Presentation

  • .potx — PowerPoint Template

  • .potm — PowerPoint Macro-Enabled Template

  • .ppsx — PowerPoint Show

  • .ppsm — PowerPoint Macro-Enabled Show

The extension of the generated presentation file depends on the extensions specified by the TemplatePath and OutputPath properties. This table shows the supported combinations.

OutputPath extensionTemplatePath extensionOutput extension
nonenone.pptx
.pptxnone.pptx
none.pptx.pptx
.pptx.pptx.pptx
none.potx.pptx
.potx.potx.potx
none.pptm.pptm
none.potm.pptm
.pptm.pptm.pptm
none.ppsx.ppsx
.ppsx.ppsx.ppsx
none.ppsm.ppsm
.ppsm.ppsm.ppsm

These extensions are not supported for either the template file or the output presentation file:

  • .ppt — PowerPoint 97–2003 Presentation

  • .pot — PowerPoint 97–2003 Template

  • .pps — PowerPoint 97–2003 Slide Show

  • .xml — PowerPoint XML Presentation

Note

Specify the OutputPath property by providing the outputPath argument or set the OutputPath property before you open the mlreportgen.ppt.Presentation object. When the Presentation object is opened, the extension of the file name in the OutputPath property is updated, based on the values of the extensions in the OutputPath and TemplatePath properties as described in the previous table.

Example: "myPresentation"

Example: "C:\myPresentations\myPresentation.pptx"

Child elements of this object, specified as a cell array of PPT objects. This property is read-only.

ID for this PPT API object, specified as a character vector or string scalar. A session-unique ID is generated as part of object creation. You can specify an ID to replace the generated ID.

Tag for this PPT API object, specified as a character vector or string scalar. A session-unique tag is generated as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object.

Specifying your own tag value can help you to identify where an issue occurred during presentation generation.

Methods

expand all

Examples

collapse all

When you create a presentation container and do not specify a template, the template that comes with the PPT API defines the default style of the slides. You can override the default style for individual slides by using format properties and objects.

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

import mlreportgen.ppt.*

Create an mlreportgen.ppt.Presentation object to contain the slides. Do not specify a template. Add a slide for the title and a slide for text.

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

titleSlide = add(ppt,'Title Slide');
textSlide  = add(ppt,'Title and Content');

Specify a title for the presentation. Make the title red by creating the title as an mlreportgen.ppt.Paragraph object and setting the FontColor format property.

paraObj = Paragraph('My First Presentation');
paraObj.FontColor = 'red';
replace(titleSlide,'Title',paraObj);

Add content to the second slide.

replace(textSlide,'Content',{'Subject A','Subject B','Subject C'});

Close and view the presentation.

close(ppt);
rptview(ppt);

Here is the generated presentation:

If the PPT API default template does not meet your formatting requirements, you can specify a different template when you create a presentation container. Use an existing presentation as a template or a customized copy of the default template. This example creates a copy of the default template to illustrate how to specify the template when you create a presentation container.

Create a copy of the PPT API default template named myTemplate.

mlreportgen.ppt.Presentation.createTemplate('myTemplate.pptx');

In PowerPoint, customize the formatting of the slide masters and slide layouts in myTemplate.pptx. See Set Up a PowerPoint Presentation Template.

Generate a presentation named myPresentation using the template myTemplate.

import mlreportgen.ppt.*
ppt = Presentation('myPresentation.pptx','myTemplate.pptx');
open(ppt);
slide = add(ppt,'Title Slide');
replace(slide,'Title','My Title');
close(ppt);
rptview(ppt);

Version History

Introduced in R2015a