EndOf
Moves or extends the ending character position of a Range or Selection. EndOf method associated with a range or selection object which helps extending the selection or move selection.
Syntax
Selection.EndOf(unit, extend)
- Unit: its an optional parameter, decides the movement of cursor in a range. The unit is derived from wdUnits enum which extends various constants like wdCell, wdCharacter, wdCharacterFormatting and so on.
- Extend: its an optional parameter, which can be used to extend the selection using WdMovementType enum having:
- wdMove : moves cursor
- wdExtend : makes selection
Code example
Public Sub EndOfExample() 'Declare selection variable Dim oSelection As Selection 'bind selection Set oSelection = Selection 'Move selection line end oSelection.EndOf Unit:=wdLine, Extend:=wdMove 'Move select rest of paragraph from current selection oSelection.EndOf Unit:=wdParagraph, Extend:=wdExtend 'Memory cleanup Set oSelection = Nothing End Sub
Output before

Output after

Next >> System Object in Microsoft Word a complete reference