Selection.MoveEnd method (Word)

Moves the ending character position of a range or selection.

Syntax

expression. MoveEnd( _Unit_ , _Count_ )

expression Required. A variable that represents a Selection object.

Parameters

Name Required/Optional Data type Description
Unit Optional WdUnits The unit by which to move the ending character position. The default value is wdCharacter.
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.

Return value

Integer

Remarks

This method returns an integer that indicates the number of units the range or selection actually moved, or it returns 0 (zero) if the move was unsuccessful.

Example

This example moves the end of the selection one character backward (the selection size is reduced by one character). A space is considered a character.

Selection.MoveEnd Unit:=wdCharacter, Count:=-1

This example moves the end of the selection to the end of the line (the selection is extended to the end of the line).

Selection.MoveEnd Unit:=wdLine, Count:=1

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.