主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

replace

类: mlreportgen.ppt.PicturePlaceholder
命名空间: mlreportgen.ppt

用图片替换图片占位符

说明

replacementPictureObj = replace(picturePlaceholder,picture) 用指定的图片替换指定的图片占位符并返回图片对象。

示例

示例

全部展开

在演示文稿中添加 Title and Picture 幻灯片,然后用您自己的标题和图片替换标题和图片占位符。

导入 PPT 命名空间,这样您就不必对 PPT API 类使用长而完全限定的名称。

import mlreportgen.ppt.*

创建演示文稿。

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

添加具有 Title and Picture 布局的幻灯片。

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

使用幻灯片对象的 find 方法查找名为 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:30:125'
                   Id: '30:125'

find 方法返回一个 mlreportgen.ppt.TextBoxPlaceholder 对象。

用标题文本替换占位符内容。

replace(titlePlaceholderObj,"Airplane");

使用幻灯片对象的 find 方法查找名为 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:31:126'
                   Id: '31:126'

find 方法返回一个 mlreportgen.ppt.PicturePlaceholder 对象。

用图片替换图片占位符。

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

关闭并查看演示文稿。

close(ppt);
rptview(ppt);

PowerPoint® 调整图片尺寸以适合图片占位符。如果图片占位符尺寸大于 Picture 对象尺寸,则图片会按比例拉伸。如果尺寸较小,则图片位于中央。

输入参数

全部展开

图片占位符,指定为 mlreportgen.ppt.PicturePlaceholder 对象。

用于替换图片占位符的图片,指定为 mlreportgen.ppt.Picture 对象。

输出参量

全部展开

替换图片,作为 mlreportgen.ppt.Picture 对象返回。

版本历史记录

在 R2015b 中推出