Class TextStyle (PowerPoint VBA)

The class TextStyle represents one of three text styles: title text, body text, or default text. Each text style contains a TextFrame object that describes how text is placed within the text bounding box, a Ruler object that contains tab stops and outline indent formatting information, and a TextStyleLevels collection that contains outline text formatting information. The TextStyle object is a member of the TextStyles collection.

Set

To use a TextStyle class variable it first needs to be instantiated, for example

Dim tse as TextStyle
Set tse = ActivePresentation.SlideMaster.TextStyles(Type:=1)

The following procedures can be used to set variables of type TextStyle: TextStyles.Item and Master.TextStyles

Levels

Returns a TextStyleLevels object that represents outline text formatting.

Dim tslsLevels As TextStyleLevels
Set tslsLevels = ActivePresentation.SlideMaster.TextStyles(1).Levels

Parent

Returns the parent object for the specified object.

Ruler

Returns a Ruler object that represents the ruler for the specified text.

Dim rlrRuler As Ruler
Set rlrRuler = ActiveWindow.Selection.SlideRange(1).TextStyles(1).Ruler

TextFrame

Returns a TextFrame object that contains the alignment and anchoring properties for the specified shape or master text style.

Use the TextRange property of the TextFrame object to return the text in the text frame. Use the HasTextFrame property to determine whether a shape contains a text frame before you apply the TextFrame property.

Dim tfeTextFrame As TextFrame
Set tfeTextFrame = ActiveWindow.Selection.SlideRange(1).TextStyles(1).TextFrame

TextStyles.Count

Returns the number of objects in the specified collection.

Dim lngCount As Long
lngCount = ActiveWindow.Selection.SlideRange(1).TextStyles.Count

TextStyles.Item

Returns a single text style from the specified TextStyles collection.

The Item method is the default member for a collection. For example, the following two lines of code are equivalent: ActivePresentation.Slides.Item(1) ActivePresentation.Slides(1) The Type parameter value can be one of these PpTextStyleType constants.

Syntax : expression.Item (Type)

Type: The text style type.

Dim tse As TextStyle
Set tse = ActivePresentation.SlideMaster.TextStyles(Type:=1)

TextStyles.Parent

Returns the parent object for the specified object.