Selection。扩展方法 (Word)Selection.Extend method (Word)

打开扩展模式。如果扩展模式已经打开,则将选定内容扩展到下一个更大的文本单位。Turns on extend mode, or if extend mode is already on, extends the selection to the next larger unit of text.

语法Syntax

表达式扩展(字符)expression.Extend (Character)

expression:必需。expression Required. 表示 Selection 对象的变量。A variable that represents a Selection object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
CharacterCharacter 可选Optional VariantVariant 通过该扩展所选内容的字符。The character through which the selection is extended. 此参数区分大小写, 并且必须计算为字符串或发生错误。This argument is case-sensitive and must evaluate to a String or an error occurs. 另外,如果该参数的值不止一个字符,则 Microsoft Word 完全忽略该命令。Also, if the value of this argument is longer than a single character, Microsoft Word ignores the command entirely.

备注Remarks

使用此方法将ExtendMode属性设置为True (如果尚不存在)。Using this method sets the ExtendMode property to True if it is not already.

逐级选定文本单位是:单词、句、段落、节和整篇文档。The progression of selected units of text is as follows: word, sentence, paragraph, section, entire document. 如果指定了 Character,则该方法正向扩展选定内容至指定字符下一次出现的位置。If Character is specified, this method extends the selection forward through the next instance of the specified character. 通过移动选定内容的活动结尾来扩展选定内容。The selection is extended by moving the active end of the selection.

示例Example

本示例将当前的选定内容折叠为一个插入点,并选择当前的语句。This example collapses the current selection to an insertion point and then selects the current sentence.

With Selection 
 ' Collapse current selection to insertion point. 
 .Collapse 
 ' Turn extend mode on. 
 .Extend 
 ' Extend selection to word. 
 .Extend 
 ' Extend selection to sentence. 
 .Extend 
End With

下面的示例在不使用Extend方法的情况下完成相同的任务。Here is an example that accomplishes the same task without the Extend method.

With Selection 
 ' Collapse current selection. 
 .Collapse 
 ' Expand selection to current sentence. 
 .Expand Unit:=wdSentence 
End With

本示例激活选定内容的结尾并将选定内容扩展至下一个以"R"开头的实例。This example makes the end of the selection active and extends the selection through the next instance of a capital "R".

With Selection 
 .StartIsActive = False 
 .Extend Character:="R" 
End Wit

另请参阅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.