Selection.SetRange method (Word)
Sets the starting and ending character positions for the selection.
expression. SetRange
( _Start_
, _End_
)
expression Required. A variable that represents a Selection object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
Start | Required | Long | The starting character position of the selection. |
End | Required | Long | The ending character position of the selection. |
Character position values start at the beginning of the story, with the first value being 0 (zero). All characters are counted, including nonprinting characters. Hidden characters are counted even if they're not displayed.
The SetRange method redefines the starting and ending positions of an existing Selection object. This method differs from the Range method, which is used to create a Range object, given a starting and ending position.
This example selects the first 10 characters in the document.
Selection.SetRange Start:=0, End:=10
This example extends the selection to the end of the document.
Selection.SetRange Start:=Selection.Start, _
End:=ActiveDocument.Content.End
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.