Range.MoveEnd method (Word)
Moves the ending character position of a range. .
Syntax
expression. MoveEnd
( _Unit_
, _Count_
)
expression Required. A variable that represents a Range object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Unit | Optional | WdUnits | The unit by which to move the ending character position. |
Count | Optional | Variant | The number of units to move. If this number is positive, the ending character position is moved forward in the document. If this number is negative, the end is moved backward. If the ending position overtakes the starting position, the range collapses and both character positions move together. The default value is 1. |
Remarks
This method returns an integer that indicates the number of units the range actually moved, or it returns 0 (zero) if the move was unsuccessful.
Example
This example sets myRange to be equal to the second word in the active document. The MoveEnd method is used to move the ending position of myRange (a range object) forward one word. After this macro is run, the second and third words in the document are selected.
If ActiveDocument.Words.Count >= 3 Then
Set myRange = ActiveDocument.Words(2)
With myRange
.MoveEnd Unit:=wdWord, Count:=1
.Select
End With
End If
See also
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.