Main Content

replace

Class: mlreportgen.ppt.TextBoxPlaceholder
Namespace: mlreportgen.ppt

Replace text box placeholder content

Description

replacementParagraphObj = replace(textBoxPlaceholder,paragraph) replaces the content in the specified text box placeholder with a paragraph and returns the paragraph object.

example

Examples

expand all

Add a title slide to a presentation and then replace the slide placeholders for the title and subtitle with your title and subtitle text.

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.

ppt = Presentation("myTextBoxPlaceholderPresentation.pptx");
open(ppt);

Add a title slide.

slide = add(ppt,"Title Slide");

Use the find method of the slide object to find the placeholder object that has the name Title.

titlePlaceholderObj = find(slide,"Title")
titlePlaceholderObj = 
  TextBoxPlaceholder with properties:

                 Bold: []
                 Font: []
    ComplexScriptFont: []
            FontColor: []
             FontSize: []
               Italic: []
               Strike: []
            Subscript: []
          Superscript: []
            Underline: []
      BackgroundColor: []
               VAlign: []
                 Name: 'Title'
                    X: '1524000emu'
                    Y: '1122363emu'
                Width: '9144000emu'
               Height: '2387600emu'
                Style: []
             Children: []
               Parent: [1×1 mlreportgen.ppt.Slide]
                  Tag: 'ppt.TextBoxPlaceholder:431:407'
                   Id: '431:407'

The find method returns an mlreportgen.ppt.TextBoxPlaceholder object.

Replace the placeholder content with the title text.

replace(titlePlaceholderObj(1),"My Title");

Find the placeholder object for the subtitle.

subtitlePlaceholderObj = find(slide,"Subtitle")
subtitlePlaceholderObj = 
  TextBoxPlaceholder with properties:

                 Bold: []
                 Font: []
    ComplexScriptFont: []
            FontColor: []
             FontSize: []
               Italic: []
               Strike: []
            Subscript: []
          Superscript: []
            Underline: []
      BackgroundColor: []
               VAlign: []
                 Name: 'Subtitle'
                    X: '1524000emu'
                    Y: '3602038emu'
                Width: '9144000emu'
               Height: '1655762emu'
                Style: []
             Children: []
               Parent: [1×1 mlreportgen.ppt.Slide]
                  Tag: 'ppt.TextBoxPlaceholder:432:408'
                   Id: '432:408'

The placeholder object for the subtitle is also an mlreportgen.ppt.TextBoxPlaceholder object.

Replace the placeholder content with the text for the subtitle.

replace(subtitlePlaceholderObj(1),"My Subtitle");

Close and view the presentation.

close(ppt);
rptview(ppt);

Here is the title slide in the generated presentation:

Input Arguments

expand all

Text box placeholder, specified as an mlreportgen.ppt.TextBoxPlaceholder object.

Paragraph to use as the replacement for the text box placeholder content, specified as a character vector, string scalar, or mlreportgen.ppt.Paragraph object.

Output Arguments

expand all

Replacement paragraph, returned as an mlreportgen.ppt.Paragraph object.

Version History

Introduced in R2015b