Extend Method

Microsoft Word Visual Basic

property to True), or if extend mode is already on, extends the selection to the next larger unit of text. The progression of selected units of text is as follows: word, sentence, paragraph, section, entire document.

If Character is specified, extends the selection forward through the next instance of the specified character. The selection is extended by moving the active end of the selection.

expression.Extend(Character)

expression    Required. An expression that returns one of the objects in the Applies To list.

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.

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