replace

Class: mlreportgen.ppt.TemplatePicture
Package: mlreportgen.ppt

Replace template picture with another picture

Syntax

newPicture = replace(templatePicture,replacementPicture)

Description

newPicture = replace(templatePicture,replacementPicture) replaces a template picture with another picture.

Input Arguments

expand all

Template picture to replace, specified as an mlreportgen.ppt.TemplatePicture object.

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

Output Arguments

expand all

New picture in the presentation slide, specified as an mlreportgen.ppt.Picture object.

Examples

expand all

Generate a presentation, MyPicturePresentation, that you then use as the template presentation for another presentation. MyPicturePresentation has one slide with one picture.

import mlreportgen.ppt.*
ppt = Presentation("MyPicturePresentation");
open(ppt);
slide1 = add(ppt,"Title and Picture");
replace(slide1,"Title","Street");
replace(slide1,"Picture",Picture("street1.jpg"));

Close and view the presentation.

close(ppt);
rptview(ppt);

Create a presentation, MyNewPicturePresentation, from MyPicturePresentation. MyPicturePresentation is the template presentation for MyNewPicturePresentation,

ppt = Presentation("MyNewPicturePresentation","MyPicturePresentation");
open(ppt);

Find the template picture by using the find method of the slide object. Because the picture comes from a template presentation slide, find returns the picture as an mlreportgen.ppt.TemplatePicture object.

slide1 = ppt.Children(1);
templatePictureObj = find(slide1,"Picture") 
templatePictureObj = 
  TemplatePicture with properties:

    XMLMarkup: '<p:pic><p:nvPicPr><p:cNvPr id="8" name="Picture"/><p:cNvPicPr><a:picLocks noChangeAspect="1" noGrp="1"/></p:cNvPicPr><p:nvPr><p:ph idx="13" sz="quarter" type="pic"/></p:nvPr></p:nvPicPr><p:blipFill><a:blip r:embed="rId2"/><a:stretch><a:fillRect/></a:stretch></p:blipFill><p:spPr/></p:pic>'
         Name: 'Picture'
            X: []
            Y: []
        Width: []
       Height: []
        Style: []
     Children: []
       Parent: [1×1 mlreportgen.ppt.Slide]
          Tag: 'ppt.TemplatePicture:1360:550'
           Id: '1360:550'

Replace the picture with a different picture.

street2 = Picture("street2.jpg");
replace(templatePictureObj,street2);

Close and view the presentation.

close(ppt);
rptview(ppt);

Introduced in R2019b