StartOf Method

See Also         Example         Applies To

Moves or extends the start position of the specified range or selection to the beginning of the nearest specified text unit. This method returns a value that indicates the number of characters by which the range or selection was moved or extended. The method returns a negative number if the movement is backward through the document.

Syntax

expression.StartOf(Unit, Extend)

expression   Required. An expression that returns a Range or Selection object.

Unit   Optional Variant. The unit by which the start position of the specified range or selection is to be moved. Can be one of the following WdUnits constants: wdCell, wdCharacter, wdColumn, wdParagraph, wdRow, wdSection, wdSentence, wdStory, wdTable, or wdWord. If expression returns a Selection object, you can also use wdLine. The default value is wdWord.

Extend   Optional Variant. Can be either of the following WdMovementType constants: wdMove or wdExtend. If you use wdMove, both ends of the range or selection are moved to the beginning of the specified unit. If you use wdExtend, the beginning of the range or selection is extended to the beginning of the specified unit. The default value is wdMove.

Remarks

If the beginning of the specified range or selection is already at the beginning of the specified unit, this method doesn't move or extend the range or selection. For example, if the selection is at the beginning of a line, the following example returns 0 (zero) and doesn't change the selection.

char = Selection.StartOf(Unit:=wdLine, Extend:=wdMove)