Main Content

replace

Class: mlreportgen.ppt.PicturePlaceholder
Package: mlreportgen.ppt

Replace picture placeholder with picture

Description

example

replacementPictureObj = replace(picturePlaceholder,picture) replaces the specified picture placeholder with the specified picture and returns the picture object.

Examples

expand all

Add a Title and Picture slide to a presentation and then replace the title and picture placeholders with your own title and picture.

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 a presentation.

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

Add a slide that has a Title and Picture layout.

slide = add(ppt,"Title and Picture");

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: []
                    Y: []
                Width: []
               Height: []
                Style: []
             Children: []
               Parent: [1×1 mlreportgen.ppt.Slide]
                  Tag: 'ppt.TextBoxPlaceholder:6:9'
                   Id: '6:9'

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

Replace the placeholder content with the title text.

replace(titlePlaceholderObj,"Airplane");

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

picturePlaceholderObj = find(slide,"Picture")
picturePlaceholderObj = 
  PicturePlaceholder with properties:

                 Bold: []
                 Font: []
    ComplexScriptFont: []
            FontColor: []
             FontSize: []
               Italic: []
               Strike: []
            Subscript: []
          Superscript: []
            Underline: []
      BackgroundColor: []
               VAlign: []
                 Name: 'Picture'
                    X: []
                    Y: []
                Width: []
               Height: []
                Style: []
             Children: []
               Parent: [1×1 mlreportgen.ppt.Slide]
                  Tag: 'ppt.PicturePlaceholder:7:10'
                   Id: '7:10'

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

Replace the picture placeholder with a picture.

replace(picturePlaceholderObj,Picture("b747.jpg"));

Close and view the presentation

close(ppt);
rptview(ppt);

Input Arguments

expand all

Picture placeholder, specified as an mlreportgen.ppt.PicturePlaceholder object.

Picture to use as the replacement for the picture placeholder, specified as an mlreportgen.ppt.Picture object.

Output Arguments

expand all

Replacement picture, returned as an mlreportgen.ppt.Picture object.

Introduced in R2015b