VBA - Expanding
Range.Expand
Expands the Range or Selection object by a particular unit.
Unit - The default is wdWord. The unit can only be one of the following constants:
Using any other unit will generate a Bad Paramater error.
You can only use wdLine when using a Selection object.
This method returns a value (Long) that indicates the number of characters added to the Range.
The following expands the Range object to include another sentence
You can also define the start and end points of a range by using the Start and End properties of a range.
The following example creates a Range object that refers to the third and fourth sentences in the active document.
Expanding a range to include the whole document
There a several ways you can change a given Range object
Range.SetRange
This redefines the starting and end position of existing selection or range
All characters are counted including non printable characters and hidden characters.
This line of code will set the insertion point to the beginning of the active document
Range.StartOf
Its is also possible to refines the starting and end position of a range by a specific number of units
Extend has the default of wdMove
When wdMove is used both the ends of the range are moved to the beginning , ie the range is collapsed to a point.
Note: The beginning of the range is not moved if the range is already at the beginning of the specified unit.
Range.EndOf
When wdMove is used both ends of the range are moved to the end, ie the range is collapsed to a point.
HomeKey
EndKey
Returns a range representing the resulting insertion point
Extends to the next complete unit
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext