Main Content


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

Replace text, tables, or pictures in presentation



replace(presentation,contentName,content) replaces existing content in a presentation content object with the specified content which can be one or more paragraphs, a table, or a picture. If the type of content that you specify in the content argument is not valid for the content object identified by contentName, the replace method has no effect.


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 a presentation and add two slides that have titles.

ppt = Presentation('myPresentation.pptx');
add(ppt,'Title Slide');
add(ppt,'Title and Content');

Replace all the titles in the presentation with the title My Slide Title.

replace(ppt,'Title','My Slide Title');

Close and view the presentation.


Input Arguments

expand all

Presentation to replace content in, specified as an mlreportgen.ppt.Presentation object.

Name property value of the objects that contain the content that you want to replace, specified as a character vector or string scalar.

When you add a slide to a presentation, the add method sets the Name property of the content objects on the slide based on the slide layout. See getLayoutNames. The Name property values include:

  • 'Title'

  • 'Content'

  • 'Table'

  • 'Picture'

  • 'Text'

  • 'Vertical Text'

The Name property can also be set to a custom value.

Replacement content, specified as one of these values:

  • character vector or string scalar

  • mlreportgen.ppt.Paragaph object

  • cell array of character vectors or Paragraph objects, or a combination of both

  • string array

  • mlreportgen.ppt.Table object

  • mlreportgen.ppt.Picture object


Version History

Introduced in R2015b