Main Content

mlreportgen.ppt.TextBoxPlaceholder class

Package: mlreportgen.ppt

Placeholder for slide title

Description

An object of the mlreportgen.ppt.TextBoxPlaceholder class is a placeholder for a slide title. When you add a slide with a title to a presentation, the PPT API creates a TextBoxPlaceholder object for the title. All slide layouts in the default PPT API, except Blank, have a title. To find a TextBoxPlaceholder object, use the find method of the slide that contains the title. Then, you can set the properties of the TextBoxPlaceholder object to specify the default format for the title text that replaces the placeholder content. To replace the placeholder content with your title text, use the replace method of the TextBoxPlaceholder object. The replace method does not replace the TextBoxPlaceholder object. It adds the text as one or more paragraphs to the Children property of the TextBoxPlaceholder object.

The mlreportgen.ppt.TextBoxPlaceholder 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. Specify true for bold 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.

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, to render 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.

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

Whether to use italic for the text, specified as true or false. Specify true for italic 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

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

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.

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

Background color for the text box 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.

Vertical alignment of the title text in the text box 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 text box placeholder

'bottom'

Vertically aligned to the bottom of the text box placeholder

'middle'

Vertically aligned to the middle of the text box placeholder

'topCentered'

Vertically aligned to the top and horizontally aligned to the center of the text box placeholder

'bottomCentered'

Vertically aligned to the bottom and horizontally aligned to the center of the text box placeholder

'middleCentered'

Vertically aligned to the middle and horizontally aligned to the center of the text box placeholder

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

Upper left x-coordinate of the position of the text box 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 text box 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 text box 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

Height of the text box 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

Text box placeholder formatting, specified as a cell array of PPT format objects. Formats that do not apply to a TextBoxPlaceholder object are ignored.

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.*
slide = add(ppt,"Title Slide");
content = find(slide,"Title");
placeholderObj = content(1);
placeholderObj.Style = [placeholderObj.Style {Bold(true),FontColor("red")}];
replace(placeholderObj,'Test');

See Presentation Formatting Approaches.

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 a title slide to a presentation and then replace the slide placeholders for the title and subtitle with your title and subtitle text.

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

Add a title slide.

slide = add(ppt,"Title Slide");

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: '1524000emu'
                    Y: '1122363emu'
                Width: '9144000emu'
               Height: '2387600emu'
                Style: []
             Children: []
               Parent: [1×1 mlreportgen.ppt.Slide]
                  Tag: 'ppt.TextBoxPlaceholder:21:61'
                   Id: '21:61'

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

Replace the placeholder content with the title text.

replace(titlePlaceholderObj(1),"My Title");

Find the placeholder object for the subtitle.

subtitlePlaceholderObj = find(slide,"Subtitle")
subtitlePlaceholderObj = 
  TextBoxPlaceholder with properties:

                 Bold: []
                 Font: []
    ComplexScriptFont: []
            FontColor: []
             FontSize: []
               Italic: []
               Strike: []
            Subscript: []
          Superscript: []
            Underline: []
      BackgroundColor: []
               VAlign: []
                 Name: 'Subtitle'
                    X: '1524000emu'
                    Y: '3602038emu'
                Width: '9144000emu'
               Height: '1655762emu'
                Style: []
             Children: []
               Parent: [1×1 mlreportgen.ppt.Slide]
                  Tag: 'ppt.TextBoxPlaceholder:22:62'
                   Id: '22:62'

The placeholder object for the subtitle is also an mlreportgen.ppt.TextBoxPlaceholder object.

Replace the placeholder content with the text for the subtitle.

replace(subtitlePlaceholderObj(1),"My Subtitle");

Close and view the presentation.

close(ppt);
rptview(ppt);

Here is the title slide in the generated presentation:

To add a paragraph to a slide title, use the add method of the TextBoxPlaceholder object that represents the title. This example creates a presentation with a Title and Table slide and then creates a second presentation from the first presentation. In the second presentation, the example adds content to the title of the Title and Table slide.

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 and add a Title and Table slide to the presentation.

ppt = Presentation("myPPT1.pptx");
open(ppt);
slide = add(ppt,"Title and Table");

Find the text box placeholder for the title and replace the content.

contents = find(slide,"Title");
replace(contents(1),"Hello World");

Close and view the presentation.

close(ppt);
rptview(ppt);

Here is the title slide in the generated presentation:

Create a second presentation, using the first presentation as the template.

ppt = Presentation("myPPT2.pptx","myPPT1.pptx");
open(ppt);

Find the text box placeholder for the title and add content to the title.

contents = find(ppt,"Title");
add(contents(1)," -- How are You?");

Close and view the presentation.

close(ppt);
rptview(ppt)

In the second presentation, the title has the content from the template presentation and the added content.

Tips

  • If you add a slide with a layout that has a placeholder for text that is not a title, the PPT API creates an mlreportgen.ppt.BodyPlaceholder or mlreportgen.ppt.ContentPlaceholder object.

  • 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