주요 콘텐츠

mlreportgen.ppt.TextBoxPlaceholder Class

Namespace: 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

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.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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

FormatValue
CSS color nameSpecify a CSS color name. For a list of CSS color names, see https://www.w3.org/wiki/CSS/Properties/color/keywords.
Hexadecimal RGB valueUse the format "#RRGGBB". Use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. You can use uppercase or lowercase letters.

Example: "red" specifies a red color using a CSS color name.

Example: "#0000ff" specifies a blue color using a hexadecimal RGB value.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Font size of the text, specified as a character vector or string scalar that contains 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

You can also specify pixels by omitting the unit. For example, "5" specifies 5 pixels.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Whether to use bold for the text, specified as a logical 1 (true) or 0 (false). When you specify:

  • 1 (true) — Render text in bold.

  • 0 (false) — Render text in regular weight.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: logical

Whether to use italic for the text, specified as a logical 1 (true) or 0 (false). When you specify:

  • 1 (true) — Render text in italic.

  • 0 (false) — Render text as straight text.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

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

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Whether to display the text as a subscript, specified as a logical 1 (true) or 0 (false). When you specify:. If Subscript is 1 (true), text renders as a subscript. If Subscript is 0 (false), text renders as regular text.

  • 1 (true) — Render text as a subscript.

  • 0 (false) — Render text in regular text.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: logical

Whether to display the document element as a superscript, specified as a logical 1 (true) or 0 (false). When you specify:

  • 1 (true) — Render document element as a superscript.

  • 0 (false) — Render document element in regular text.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

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

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Background color, specified as a character vector or string scalar that contains a CSS color name or hexadecimal RGB value.

FormatValue
CSS color nameSpecify a CSS color name. For a list of CSS color names, see https://www.w3.org/wiki/CSS/Properties/color/keywords.
Hexadecimal RGB valueUse the format "#RRGGBB". Use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. You can use uppercase or lowercase letters.

Setting the BackgroundColor property adds a mlreportgen.ppt.BackgroundColor format object to the Style property. Setting the BackgroundColor property to an empty value removes the object.

Example: "red" specifies a red color using a CSS color name.

Example: "#0000ff" specifies a blue color using a hexadecimal RGB value.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Vertical alignment of the text, specified as one of these values:

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

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Placeholder name, specified as a character vector or string scalar.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Upper-left x-coordinate position, specified as a character vector or string scalar that contains 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

You can also specify pixels by omitting the unit. For example, "5" specifies 5 pixels.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Upper-left y-coordinate position, specified as a character vector or string scalar that contains 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

You can also specify pixels by omitting the unit. For example, "5" specifies 5 pixels.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Width of the placeholder, specified as a character vector or string scalar that contains 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

You can also specify pixels by omitting the unit. For example, "5" specifies 5 pixels.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Height of the placeholder, specified as a character vector or string scalar that contains 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

You can also specify pixels by omitting the unit. For example, "5" specifies 5 pixels.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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.*
ppt = Presentation;

slide = add(ppt,"Title Slide");
content = find(slide,"Title");
placeholderObj = content(1);
placeholderObj.Style = [placeholderObj.Style {Bold(true),FontColor("red")}];

See Presentation Formatting Approaches.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

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

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

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

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Data Types: cell

Tag, 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. Use this value to help identify where an issue occurs during presentation generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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 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("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:431:407'
                   Id: '431:407'

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:432:408'
                   Id: '432:408'

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 namespace 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 generate the presentation.

close(ppt);

Here is the title slide in the generated presentation:

Slide with a single line of text reading “Hello World” positioned near the upper left, with the date and slide number in the lower corners.

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.

Slide showing two lines of text near the upper left: “Hello World” and a second indented line reading “-- How are You?”, with the date and slide number in the lower corners.

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'

Version History

Introduced in R2015b