PowerPoint) (TextFrame2 物件
代表 Shape 或 ShapeRange 物件中的文字圖文框。 會包含文字圖文框中的文字並公開用來控制文字圖文框之對齊與錨定的屬性和方法。
註解
使用 Shape 及 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 支援與意見反應。