"选择"。 Text 属性 (Word)Selection.Text property (Word)

返回或设置指定的选定内容中的文本。Returns or sets the text in the specified selection. 读/写 StringRead/write String.

语法Syntax

表达式文本expression.Text

_表达式_一个代表**Selection** 对象的变量。expression A variable that represents a Selection object.

说明Remarks

Text属性返回选定内容的无格式纯文本。The Text property returns the plain, unformatted text of the selection. 设置该属性,可替换该区域或选定内容的文本。When you set this property, the text of the range or selection is replaced.

示例Example

本示例显示选定区域中的文本。This example displays the text in the selection. 如果没有选中任何内容,则显示插入点之后的字符。If nothing is selected, the character following the insertion point is displayed.

MsgBox Selection.Text

本示例在新文档中插入 10 行文字。This example inserts 10 lines of text into a new document.

Documents.Add 
For i = 1 To 10 
 Selection.Text = "Line" & Str(i) & Chr(13) 
 Selection.MoveDown Unit:=wdParagraph, Count:=1 
Next i

另请参阅See also

Selection 对象Selection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.