CollapseOutline Method
TOC
Collapse the table of content
Expand the table of content

View.CollapseOutline Method (Word)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Collapses the text under the selection or the specified range by one heading level.

expression .CollapseOutline(Range)

expression Required. A variable that represents a View object.

Parameters

Name

Required/Optional

Data Type

Description

Range

Optional

Range object

The range of paragraphs to be collapsed. If this argument is omitted, the entire selection is collapsed.

If the document isn't in outline or master document view, an error occurs.

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 ActiveDocument.ActiveWindow.View 
 .Type = wdOutlineView 
 .CollapseOutline Range:=ActiveDocument.Paragraphs(2).Range 
End With

This example collapses every heading in the document by one level.

With ActiveDocument.ActiveWindow.View 
 .Type = wdOutlineView 
 .CollapseOutline Range:=ActiveDocument.Content 
End With

Concepts

Other resources

Show:
© 2016 Microsoft