Class TextFrame (PowerPoint VBA)

The class TextFrame represents the text frame in a Shape object. Contains the text in the text frame and the properties and methods that control the alignment and anchoring of the text frame.

Set

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

Dim tfe as TextFrame
Set tfe = ActiveWindow.RangeFromPoint.TextFrame

The following procedures can be used to set variables of type TextFrame: Shape.TextFrame, ShapeRange.TextFrame and TextStyle.TextFrame

Properties

AutoSize returns or sets a value that indicates whether the size of the specified shape is changed automatically to fit text within its boundaries.

ActivePresentation.Slides(1).Shapes(1).TextFrame.AutoSize = ppAutoSizeMixed

HasText returns whether the specified shape has text associated with it.

Dim mtsHasText As Office.MsoTriState
mtsHasText = ActivePresentation.Slides(1).Shapes(1).TextFrame.HasText

HorizontalAnchor returns or sets the horizontal alignment of text in a text frame.

ActivePresentation.Slides(1).Shapes(1).TextFrame.HorizontalAnchor = msoHorizontalAnchorMixed

MarginBottom returns or sets the distance (in points) between the bottom of the text frame and the bottom of the inscribed rectangle of the shape that contains the text.

ActivePresentation.Slides(1).Shapes(1).TextFrame.MarginBottom = 5

MarginLeft returns or sets the distance (in points) between the left edge of the text frame and the left edge of the inscribed rectangle of the shape that contains the text.

ActivePresentation.Slides(1).Shapes(1).TextFrame.MarginLeft = 5

MarginRight returns or sets the distance (in points) between the right edge of the text frame and the right edge of the inscribed rectangle of the shape that contains the text.

ActivePresentation.Slides(1).Shapes(1).TextFrame.MarginRight = 5

MarginTop returns or sets the distance (in points) between the top of the text frame and the top of the inscribed rectangle of the shape that contains the text.

ActivePresentation.Slides(1).Shapes(1).TextFrame.MarginTop = 5

Orientation returns or sets text orientation.

ActivePresentation.Slides(1).Shapes(1).TextFrame.Orientation = msoTextOrientationMixed

Parent returns the parent object for the specified object.

Dim objParent As Object
Set objParent = ActiveWindow.RangeFromPoint.TextFrame.Parent

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

Dim rlrRuler As Ruler
Set rlrRuler = ActivePresentation.Slides(1).Shapes(1).TextFrame.Ruler

TextRange returns a TextRange object that represents the text in the specified text frame.

Dim treTextRange As TextRange
Set treTextRange = ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange

VerticalAnchor returns or sets the vertical alignment of text in a text frame.

ActivePresentation.Slides(1).Shapes(1).TextFrame.VerticalAnchor = msoVerticalAnchorMixed

WordWrap determines whether lines break automatically to fit inside the shape.

ActiveWindow.RangeFromPoint.TextFrame.WordWrap = msoTrue