Main Content

mlreportgen.ppt.ContentPlaceholder Class

Namespace: mlreportgen.ppt

Placeholder for slide content

Description

An object of the mlreportgen.ppt.ContentPlaceholder class represents a content placeholder in a slide. You can replace a content placeholder with a picture, table, or one or more paragraphs.

The PPT API creates a ContentPlaceholder object when you add a slide to a presentation and the slide layout has a content placeholder. In the default PPT API, these layouts have one or more content placeholders:

  • 'Title and Content'

  • 'Two Content'

  • 'Comparison'

  • 'Content with Caption'

To find a ContentPlaceholder object, use the find method of the slide that contains the content placeholder. To replace the content placeholder with a picture, table, or one or more paragraphs, use the replace method of the ContentPlaceholder object. For a picture or table, the replace method replaces the ContentPlaceholder object with an mlreportgen.ppt.Picture or mlreportgen.ppt.Table object, respectively. For paragraphs, the PPT API does not replace the ContentPlaceholder object. It adds mlreportgen.ppt.Paragraph objects as children of the ContentPlaceholder object.

When you replace a ContentPlaceholder object with a Table or Picture object, some of the ContentPlaceholder object properties do not apply to the replacement content. For details, see Properties.

Note

If you replace a content placeholder with a picture, Microsoft® PowerPoint® adjusts the size of the content placeholder to accommodate the size of the picture. If you want the placeholder position and size to be fixed in a slide, use a slide with a picture placeholder. See mlreportgen.ppt.PicturePlaceholder.

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

Class Attributes

HandleCompatible
true
ConstructOnLoad
true

For information on class attributes, see Class Attributes.

Properties

expand all

Whether to use bold for the text, specified as true or false. A setting of true renders the text in bold. A setting of false uses regular weight text.

This property applies only when you replace the content of the content placeholder with text.

Data Types: logical

Font family for the text, specified as a character vector or string scalar. Specify a font that appears in the font list in Microsoft PowerPoint. To see the font list, in PowerPoint, on the Home tab, in the Font group, click the arrow to the right of the font.

This property applies only when you replace the content of the content placeholder with text.

Font family for complex scripts, specified as a character vector or string scalar. Specify a font family to use when substituting in a locale that requires a complex script, such as Arabic or Asian, for rendering text.

This property applies only when you replace the content of the content placeholder with text.

Font color for the text, specified as a character vector or string scalar that consists of a CSS color name or hexadecimal RGB value.

This property applies only when you replace the content of the content placeholder with text.

Font size of the text, specified as a character vector or string scalar that consists of a number followed by a unit of measurement. For example, '11pt' specifies 11 points. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

This property applies only when you replace the content of the content placeholder with text.

Whether to use italic for the text, specified as true or false. A setting of true renders the text in italic.

This property applies only when you replace the content of the content placeholder with text.

Data Types: logical

Strikethrough style for the text, specified as one of these values:

  • 'single' — Single horizontal line

  • 'none' — No strikethrough line

  • 'double' — Double horizontal line

This property applies only when you replace the content of the content placeholder with text.

Whether to display the text as a subscript, specified as true or false. A setting of true renders the text as a subscript.

This property applies only when you replace the content of the content placeholder with text.

Data Types: logical

Whether to display the text as a superscript, specified as true or false. A setting of true renders the text as a superscript.

This property applies only when you replace the content of the content placeholder with text.

Data Types: logical

Underline style for the text, specified as one of these values:

ValueDescription
'single'Single underline
'double'Double underline
'heavy'Thick underline
'words'Only words underlined (not spaces)
'dotted'Dotted underline
'dottedheavy'Thick, dotted underline
'dash'Dashed underline
'dashheavy'Thick, dashed underline
'dashlong'Long, dashed underline
'dashlongheavy'Thick, long, dashed underline
'dotdash'Dot-dash underline
'dotdashheavy'Thick, dot-dash underline
'dotdotdash'Dot-dot-dash underline
'dotdotdashheavy'Thick, dot-dot-dash underline
'wavy'Wavy underline
'wavyheavy'Thick, wavy underline
'wavydouble'Wavy, double underline
'none'No underline

This property applies only when you replace the content of the content placeholder with text.

Background color for the content placeholder, specified as a character vector or string scalar that consists of a CSS color name or hexadecimal RGB value.

This property applies only when you replace the content of the content placeholder with text.

Vertical alignment of the text in the content placeholder, specified as a character vector or string scalar. Specify one of the values in the table.

ValueDescription

'top'

Vertically aligned to the top

'bottom'

Vertically aligned to the bottom of the table entry

'middle'

Vertically aligned to the middle of the table entry

'topCentered'

Vertically aligned to the top and horizontally aligned to the center of the table entry

'bottomCentered'

Vertically aligned to the bottom and horizontally aligned to the center of the table entry

'middleCentered'

Vertically aligned to the middle and horizontally aligned to the center of the table entry

This property applies only when you replace the content of the content placeholder with text.

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

Attributes:

NonCopyable
true

Data Types: char | string

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

Note

When the PPT API creates an mlreportgen.ppt.ContentPlaceholder object, this property value is specified in English Metric Units (EMU). If you set this property, you must use one of the units in the previous list.

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

Note

When the PPT API creates an mlreportgen.ppt.ContentPlaceholder object, this property value is specified in English Metric Units (EMU). If you set this property, you must use one of the units in the previous list.

Attributes:

NonCopyable
true

Data Types: char | string

Width of the content placeholder, 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

This property does not apply when the content placeholder is replaced with a picture.

Height of the content placeholder, 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

This property does not apply when the content placeholder is replaced with a picture.

Content placeholder formatting, specified as a cell array of PPT format objects.

Add format objects by concatenating the existing value of the Style property with a cell array that contains the format objects that you are adding. For example:

import mlreportgen.ppt.*
ppt = Presentation("My Presentation");
slide = add(ppt,"Title and Content");
content = find(slide,"Content");
placeholderObj = content(1);
placeholderObj.Style = [placeholderObj.Style {Bold(true),FontColor("red")}];
replace(placeholderObj,'Test');

See Presentation Formatting Approaches.

This property applies only when you replace the content of the content placeholder with text.

Child elements of mlreportgen.ppt.ContentPlaceholder object, specified as a cell array of PPT API objects.

Attributes:

NonCopyable
true

Parent of this object, specified as a PPT API object. A PPT API object must only have one parent.

Attributes:

SetAccess
private
NonCopyable
true

Object identifier for the mlreportgen.ppt.ContentPlaceholder object, specified as a character vector or string scalar. The PPT API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for the mlreportgen.ppt.ContentPlaceholder object, specified as a character vector or string scalar. The PPT API generates a session-unique tag 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. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

Methods

expand all

Examples

collapse all

Add four Title and Content slides to a presentation. Replace the content placeholder of the first slide with text, the second slide with a table, the third slide with a picture, and the fourth slide with a multilevel list.

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("myContentPlaceholderPresentation.pptx");
open(ppt);

Add a slide with a Title and Content layout.

slide1 = add(ppt,"Title and Content");

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

titlePlaceholderObj1 = find(slide1,"Title");

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

Replace the placeholder content with the title text.

replace(titlePlaceholderObj1,"Content Replaced with Paragraph");

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

contentPlaceholderObj1 = find(slide1,"Content");

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

Replace the placeholder content with a paragraph.

replace(contentPlaceholderObj1,Paragraph("This is my paragaph"));

Add a second slide with a Title and Content layout.

slide2 = add(ppt,"Title and Content");

Replace the placeholder for the title with the title text.

titlePlaceholderObj2 = find(slide2,"Title");
replace(titlePlaceholderObj2,"Content Replaced with Table for Order 2 Magic Square");

Replace the content placeholder with a table.

contentPlaceholderObj2 = find(slide2,"Content");
replace(contentPlaceholderObj2,Table(magic(2)));

Add a third slide with a Title and Content layout.

slide3 = add(ppt,"Title and Content");

Replace the placeholder for the title with the title text.

titlePlaceholderObj3 = find(slide3,"Title");
replace(titlePlaceholderObj3,"Content Replaced with Picture of Peppers");

Replace the content placeholder with a picture.

contentPlaceholderObj3 = find(slide3,"Content");
replace(contentPlaceholderObj3,Picture("peppers.png"));

Add a fourth slide with a Title and Content layout.

slide4 = add(ppt,"Title and Content");

Replace the placeholder for the title with the title text.

titlePlaceholderObj4 = find(slide4,"Title");
replace(titlePlaceholderObj4,"Content Replaced with a Multilevel List");

Create content for a multilevel list. You can represent a multilevel list as a cell array that contains one or more cell arrays that represent sublists. Use an mlreportgen.ppt.Paragraph object to format an item in the list.

greenTea = Paragraph("Green Tea");
greenTea.FontColor = "green";

multilevelContent = { ...
    "Coffee", ...
    "Tea", ...
    { ...
        "Black Tea", ...
        greenTea, ...
    }, ...
    "Milk", ...
    };

Replace the Content placeholder with the multilevel list content.

contentPlaceholderObj4 = find(slide4,"Content");
replace(contentPlaceholderObj4,multilevelContent);

Close and view the presentation.

close(ppt);
rptview(ppt);

Here are the generated slides:

Tips

  • When you replace placeholder content in a presentation and then use the presentation as a template for a new presentation, the object that the PPT API creates for the content in the new presentation depends on the type of content, as shown in the table.

    Replacement ContentClass of Object in New Presentation
    picturemlreportgen.ppt.TemplatePicture
    tablemlreportgen.ppt.TemplateTable
    paragraphmlreportgen.ppt.ContentPlaceholder

    For more information, see Add and Replace Presentation Content.

  • 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 Content slide to a presentation, the Children property is an array that contains an mlreportgen.ppt.TextBoxPlaceholder object and an mlreportgen.ppt.ContentPlaceholder object.

    ppt = mlreportgen.ppt.Presentation("test.pptx");
    open(ppt);
    slide = add(ppt,"Title and Content");
    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:11'
                       Id: '6:11'

    slide.Children(2)
    
    ans = 
    
      ContentPlaceholder with properties:
    
                     Bold: []
                     Font: []
        ComplexScriptFont: []
                FontColor: []
                 FontSize: []
                   Italic: []
                   Strike: []
                Subscript: []
              Superscript: []
                Underline: []
          BackgroundColor: []
                   VAlign: []
                     Name: 'Content'
                        X: []
                        Y: []
                    Width: []
                   Height: []
                    Style: []
                 Children: []
                   Parent: [1×1 mlreportgen.ppt.Slide]
                      Tag: 'ppt.ContentPlaceholder:7:12'
                       Id: '7:12'

Version History

Introduced in R2015b