TextFrame2 对象 (PowerPoint)
代表 Shape 或 ShapeRange 对象中的文本框。 它包含文本框中的文本,并公开控制文本框的对齐和定位的属性和方法。
备注
使用 形状 和 ShapeRange 对象的 TextFrame2 属性返回 TextFrame2 对象。
使用 HasTextFrame 属性以确定形状或形状范围的文字框架中,并使用 HasText 属性可确定文本框架中是否包含文本。
示例
下面的示例将一个矩形添加到幻灯片中,并向该矩形中添加文本,然后设置文本框的边距。
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
下面的示例演示如何使用 HasTextFrame 属性来确定一个形状的文字框架中,是否,然后如何使用 HasText 属性可确定文本框架中是否包含文本。
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
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。