Main Content

mlreportgen.ppt.PicturePlaceholder Class

Namespace: mlreportgen.ppt

Placeholder for slide picture

Description

An object of the mlreportgen.ppt.PicturePlaceholder class represents a picture placeholder in a slide.

The PPT API creates a PicturePlaceholder object when you add a slide to a presentation and the slide layout that has a picture placeholder. In the default PPT API, the Title and Picture and Picture with Caption layouts have picture placeholders.

To find a PicturePlaceholder object, use the find method of the slide that contains the picture placeholder. To replace the picture placeholder with a picture, use the replace method of the PicturePlaceholder object. The replace method replaces the PicturePlaceholder object with an mlreportgen.ppt.Picture object.

Note

Microsoft® PowerPoint® adjusts the size of a picture to fit a picture placeholder. Use a slide with a picture placeholder when you want the placeholder position and size to be fixed in the slide. You can specify the location and size of a picture placeholder by modifying the slide layout in PowerPoint. See Set Up a PowerPoint Presentation Template. If the placeholder position and size do not have to be fixed, you can use a slide whose layout has a content placeholder. PowerPoint adjusts the size of a content placeholder to accommodate the size of a picture. See mlreportgen.ppt.ContentPlaceholder.

The mlreportgen.ppt.PicturePlaceholder class is a handle class.

Class Attributes

HandleCompatible
true
ConstructOnLoad
true

For information on class attributes, see Class Attributes.

Properties

expand all

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

Picture placeholder name, specified as a character vector or string scalar.

Upper-left x-coordinate position, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, "5in" specifies five inches. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

Attributes:

NonCopyable
true

Data Types: char | string

Upper-left y-coordinate position, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, "5in" specifies five inches. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

Attributes:

NonCopyable
true

Data Types: char | string

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

The class ignores this property.

Attributes:

NonCopyable
true

Child elements of this PPT API object, specified as a cell array of PPT API objects.

Attributes:

NonCopyable
true

Parent of this object, specified as a PPT object.

Attributes:

SetAccess
private
NonCopyable
true

ID for this PPT API object, specified as a character vector or string scalar. A session-unique ID is generated as part of the object creation. You can specify an ID to replace the generated ID.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for this PPT API object, specified as a character vector or string scalar. A session-unique tag is generated as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object.

Specifying your own tag value can help you to identify where issues occur during presentation generation.

Attributes:

NonCopyable
true

Data Types: char | string

Methods

expand all

Examples

collapse 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 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("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:30:125'
                   Id: '30:125'

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:31:126'
                   Id: '31:126'

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);

PowerPoint® adjusts the picture dimensions to fit in the picture placeholder. If the picture placeholder dimensions are bigger than the Picture object dimensions, the picture stretches proportionally. If the dimensions are smaller, the picture is centered.

Tips

  • When you replace a picture placeholder in a presentation with a picture and then use the presentation as a template for a new presentation, the PPT API creates an mlreportgen.ppt.TemplatePicture object for the picture in the new presentation. See Add or Replace a Picture.

  • To see the placeholder objects that the PPT API creates for a slide object, view the Children property of the slide. For example, when you add a Title and Picture slide to a presentation, the Children property is an array that contains an mlreportgen.ppt.TextBoxPlaceholder object and an mlreportgen.ppt.PicturePlaceholder object.

    ppt = mlreportgen.ppt.Presentation("test.pptx");
    open(ppt);
    slide = add(ppt,"Title and Picture");
    slide.Children(1)
    
    ans = 
    
      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'

    slide.Children(2)
    
    ans = 
    
      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'

Version History

Introduced in R2015b