Main Content

Get and Set PPT Object Properties

Most PPT objects have properties that describe the object. For example, Paragraph objects have properties such as Bold, FontColor, and Level. You can set the value of most object properties.

To get or set the property of PPT object, use dot notation:

  • Append a period to the name of a variable that references the object.

  • Add the property name after the period.

For example, this code creates a paragraph containing the text Hello World and colors the text green.

p = Paragraph('Hello World')
p = 

  Paragraph with properties:

           Bold: []
      FontColor: []
         Italic: []
         Strike: []
      Subscript: []
    Superscript: []
      Underline: []
          Level: []
          Style: []
       Children: [1x1 mlreportgen.ppt.Text]
         Parent: []
            Tag: 'ppt.Paragraph:1534'
             Id: '1534'
p.FontColor = 'green';

This code displays the properties of the first child of the paragraph p.

p.Children
ans = 

  Text with properties:

        Content: 'Hello World'
           Bold: []
      FontColor: []
         Italic: []
         Strike: []
      Subscript: []
    Superscript: []
      Underline: []
          Style: []
       Children: []
         Parent: [1x1 mlreportgen.ppt.Paragraph]
            Tag: 'ppt.Text:1535'
             Id: '1535'

Related Examples

More About