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 Required. A variable that represents a Selection object.

Parameters

Name Required/Optional Data type Description
Character Optional Variant The character through which the selection is extended. This argument is case-sensitive and must evaluate to a String or an error occurs. Also, if the value of this argument is longer than a single character, Microsoft Word ignores the command entirely.

Remarks

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. 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

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

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 Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.