CollapseOutline Method
Applies To
View object.
Description
Collapses the text under the selection or the specified range by one heading level.
Note If the document isn't in outline or master document view, an error occurs.
Syntax
expression.CollapseOutline(Range)
expression Required. An expression that returns a View object.
Range Optional Range object. The range of paragraphs to be collapsed. If this argument is omitted, the entire selection is collapsed.
See Also
ExpandOutline method, ShowFirstLineOnly property.
Example
This example applies the Heading 2 style to the second paragraph in the active document, switches the active window to outline view, and collapses the text under the second paragraph in the document.
ActiveDocument.Paragraphs(2).Style = wdStyleHeading2
With ActiveWindow.View
.Type = wdOutlineView
.CollapseOutline Range:=ActiveDocument.Paragraphs(2).Range
End With
This example collapses every heading in the document by one level.
With ActiveWindow.View
.Type = wdOutlineView
.CollapseOutline Range:=ActiveDocument.Content
End With