Word) (TextFrame.TextRange 属性

返回一个 Range 对象,该对象代表指定文本框架中的文本。

语法

表达式TextRange

表达 返回 TextFrame 对象的表达式。

示例

本示例在活动文档中添加一个文本框,然后在文本框中添加文字。

Set myTBox = ActiveDocument.Shapes _ 
 .AddTextBox(Orientation:=msoTextOrientationHorizontal, _ 
 Left:=100, Top:=100, Width:=300, Height:=200) 
myTBox.TextFrame.TextRange = "Test Box"

本示例在活动文档的文本框 1 中添加文字。

ActiveDocument.Shapes("TextBox 1").TextFrame.TextRange _ 
 .InsertAfter("New Text")

本示例返回活动文档的文本框 1 中的文字,并显示在消息框中。

MsgBox ActiveDocument.Shapes("TextBox 1").TextFrame.TextRange.Text

另请参阅

TextFrame 对象

支持和反馈

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