TextFrame2 Interface

Represents the text frame in a CanvasShapes or ShapeRange object. Contains the text in the text frame and exposes properties and methods that control the alignment and anchoring of the text frame.

Namespace:  Microsoft.Office.Interop.PowerPoint
Assembly:  Microsoft.Office.Interop.PowerPoint (in Microsoft.Office.Interop.PowerPoint.dll)

Syntax

'Declaration
<GuidAttribute("914934F9-5A91-11CF-8700-00AA0060263B")> _
Public Interface TextFrame2
'Usage
Dim instance As TextFrame2
[GuidAttribute("914934F9-5A91-11CF-8700-00AA0060263B")]
public interface TextFrame2

Remarks

Use the TextFrame2 property of the Shape and ShapeRange objects to return a TextFrame2 object.

Use the HasTextFrame property to determine whether a shape or shape range has a text frame, and use the HasText property to determine whether the text frame contains text.

Examples

The following example adds a rectangle to a slide, adds text to the rectangle, and then sets the margins for the text frame.

Public Sub TextFrame2_Example()



    Set pptSlide = ActivePresentation.Slides(1)

    With pptSlide.Shapes.AddShape(msoShapeRectangle, 0, 0, 250, 140).TextFrame2

        .TextRange.Text = "Here is some sample text"

        .MarginBottom = 10

        .MarginLeft = 10

        .MarginRight = 10

        .MarginTop = 10

    End With

    

End Sub

The following example shows how to use the HasTextFrame property to determine whether a shape has a text frame, and then how to use the HasText property to determine whether the text frame contains text.

Public Sub HasTextFrame_Example()



    Set pptSlide = ActivePresentation.Slides(1)

    For Each pptShape In pptSlide.Shapes

        If pptShape.HasTextFrame Then

            With pptShape.TextFrame2

                If .HasText Then MsgBox .TextRange.Text

            End With

        End If

    Next

    

End Sub

See Also

Reference

TextFrame2 Members

Microsoft.Office.Interop.PowerPoint Namespace