PowerPoint) (TextFrame 对象

表示 形状 对象中的文字框架。 包含文本框中的文字框架的属性和控件的对齐方式和定位的文本框架的方法。

示例

使用 TextFrame 属性返回一个 TextFrame 对象。 下面的示例将一个矩形添加到 myDocument,将文本添加到该矩形,然后设置文本框的边距。

Set myDocument = ActivePresentation.Slides(1)

With myDocument.Shapes _

        .AddShape(msoShapeRectangle, 0, 0, 250, 140).TextFrame

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

    .MarginBottom = 10

    .MarginLeft = 10

    .MarginRight = 10

    .MarginTop = 10

End With

使用HasTextFrame确定一个形状的文字框架中,是否和使用HasText属性 属性可确定文本框架中是否包含文本,如下面的示例中所示。

Set myDocument = ActivePresentation.Slides(1)

For Each s In myDocument.Shapes

    If s.HasTextFrame Then

        With s.TextFrame

            If .HasText Then MsgBox .TextRange.Text

        End With

    End If

Next

方法

名称
DeleteText

属性

名称
Application
AutoSize
Creator
HasText
HorizontalAnchor
MarginBottom
MarginLeft
MarginRight
MarginTop
Orientation
Parent
Ruler
TextRange
VerticalAnchor
WordWrap

另请参阅

PowerPoint 对象模型引用

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。