Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Collapse Method

Office 2003

Collapses a range or selection to the starting or ending position. After a range or selection is collapsed, the starting and ending points are equal.

expression.Collapse(Direction)

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

Direction    Optional Variant. The direction in which to collapse the range or selection. Can be either of the following WdCollapseDirection constants: wdCollapseEnd or wdCollapseStart. The default value is wdCollapseStart.

Remarks

If you use wdCollapseEnd to collapse a range that refers to an entire paragraph, the range is located after the ending paragraph mark (the beginning of the next paragraph). However, you can move the range back one character by using the MoveEnd method after the range is collapsed, as shown in the following example.

Set myRange = ActiveDocument.Paragraphs(1).Range
myRange.Collapse Direction:=wdCollapseEnd
myRange.MoveEnd Unit:=wdCharacter, Count:=-1
		

Example

This example collapses the selection to an insertion point at the beginning of the previous selection.

Selection.Collapse Direction:=wdCollapseStart
		

This example sets myRange equal to the contents of the active document, collapses myRange, and then inserts a 2x2 table at the end of the document.

Set myRange = ActiveDocument.Content
myRange.Collapse Direction:=wdCollapseEnd
ActiveDocument.Tables.Add Range:=myRange, NumRows:=2, NumColumns:=2
		


See Also | End Property | Start Property


Show:
© 2015 Microsoft