View.ExpandOutline method (Word)

Expands the text under the selection by one heading level.

Syntax

expression. ExpandOutline( _Range_ )

expression Required. A variable that represents a 'View' object.

Parameters

Name Required/Optional Data type Description
Range Optional Range The range of paragraphs to be expanded. If this argument is omitted, the entire selection is expanded.

Remarks

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

Example

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

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

This example expands the active paragraph in the Document2 window.

With Windows("Document2") 
 .Activate 
 .View.Type = wdOutlineView 
 .View.ExpandOutline 
End With

See also

View Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.