Expand Method

Applies To

Range object, Selection object.

Description

Expands the specified range or selection. Returns the number of characters added to the range or selection.

Syntax

expression.Expand(Unit)

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

Unit Optional Variant. The unit by which to expand the range. Can be one of the following WdUnits constants: wdCharacter, wdWord, wdSentence, wdParagraph, wdSection, wdStory, wdCell, wdColumn, wdRow, or wdTable. If expression represents a Selection object, wdLine can also be used. The default value is wdWord.

See Also

Next method, WholeStory method.

Example

This example creates a range that refers to the first word in the active document, and then it expands the range to reference the first paragraph in the document.

Set myRange = ActiveDocument.Words(1)
myRange.Expand Unit:=wdParagraph
This example capitalizes the first character in the selection and then expands the selection to include the entire sentence.

With Selection
    .Characters(1).Case = wdTitleSentence
    .Expand Unit:=wdSentence
End With