OutlineLevel Property

Microsoft Word Visual Basic

OutlineLevel Property

       

Returns or sets the outline level for the specified paragraphs. Read/write wdOutlineLevel.

    Can be one of the following WdOutlineLevel constants.

    wdOutLineLevel1

    wdOutLineLevel2

    wdOutLineLevel3

    wdOutLineLevel4

    wdOutLineLevel5

    wdOutLineLevel6

    wdOutLineLevel7

    wdOutLineLevel8

    wdOutLineLevel9

    wdOutLineLevelBodyText.

expression.OutlineLevel

expression   Required. An expression that returns one of the objects in the Applies To list.

Remarks

If a paragraph has a heading style applied to it (Heading 1 through Heading 9), the outline level is the same as the heading style and cannot be changed.

Outline levels are visible only in outline view or the document map pane.

Example

This example returns the outline level of the first paragraph in the active document.

temp = ActiveDocument.Paragraphs(1).OutlineLevel

This example sets the outline level for each paragraph in the active document. First the Normal style is applied to all paragraphs. The Mod operator is used to determine which outline level (1, 2, or 3) to apply to successive paragraphs in the document, and then the view is changed to outline view.

Set myParas = ActiveDocument.Paragraphs
ActiveDocument.Paragraphs.Style = wdStyleNormal
For x = 1 To myParas.Count
    If x Mod 3 = 1 Then
        myParas(x).OutlineLevel = wdOutlineLevel1
    ElseIf x Mod 3 = 2 Then
        myParas(x).OutlineLevel = wdOutlineLevel2
    Else
        myParas(x).OutlineLevel = wdOutlineLevel3
    End If
Next x
ActiveDocument.ActiveWindow.View.Type = wdOutlineView