Publisher) (TextFrame.TextRange 屬性

會傳回 TextRange 物件,代表附加至圖形的文字,以及操作文字的屬性和方法。

語法

運算式TextRange

表達 代表 TextFrame 物件的變數。

範例

以下範例在使用中出版物圖案一的文字框架中新增文字,然後設定新文字的格式。 本範例假設使用中出版物第一頁內至少有一個圖案。

Sub AddTextToTextFrame() 
 With ActiveDocument.Pages(1).TextFrame.TextRange 
 .Text = "My Text" 
 With .Font 
 .Bold = msoTrue 
 .Size = 25 
 .Name = "Arial" 
 End With 
 End With 
End Sub

下列範例將矩形新增至使用中文件,並將文字加入其中。

Sub AddTextToShape() 
 With ActiveDocument.Pages(1).Shapes.AddShape(Type:=msoShapeRectangle, _ 
 Left:=72, Top:=72, Width:=250, Height:=140) 
 .TextFrame.TextRange.Text = "Here is some test text" 
 End With 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應