Main Content

mlreportgen.ppt.ContentPlaceholder class

Package: 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.

  • For a list of CSS color names, see https://www.crockford.com/wrrrld/color.html.

  • To specify a hexadecimal RGB format, use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. For example, '#0000ff' specifies blue.

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 (default)

  • 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.

  • For a list of CSS color names, see https://www.crockford.com/wrrrld/color.html.

  • To specify a hexadecimal RGB format, use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. For example, '#0000ff' specifies blue.

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

'bottom'

Vertically aligned to the bottom of the content placeholder

'middle'

Vertically aligned to the middle of the content placeholder

'topCentered'

Vertically aligned to the top and horizontally aligned to the center of the content placeholder

'bottomCentered'

Vertically aligned to the bottom and horizontally aligned to the center of the content placeholder

'middleCentered'

Vertically aligned to the middle and horizontally aligned to the center of the content placeholder

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.

Upper left x-coordinate of the position of the content placeholder in the slide, specified as a character vector or string scalar that consists of a number followed by a unit of measurement. For example, '5in' specifies 5 inches. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Upper left y-coordinate of the position of the content placeholder in the slide, specified as a character vector or string scalar that consists of a number followed by a unit of measurement. For example, '5in' specifies 5 inches. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

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 (default)

  • 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 (default)

  • 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 this object, specified as a cell array of PPT objects. This property is read-only.

Parent of this object, specified as a PPT object. This property is read-only.

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

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 an issue occurred during presentation generation.

Methods

expand all

Examples

collapse all

Add three Title and Content slides to a presentation. Replace the content placeholder of the first slide with text, the second slide with a table, and the third slide with a 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("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")
titlePlaceholderObj1 = 
  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:15:40'
                   Id: '15:40'

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")
contentPlaceholderObj1 = 
  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:16:41'
                   Id: '16:41'

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

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'
Introduced in R2015b