Level Property

Microsoft Word Visual Basic

Returns or sets the level for the heading style in a table of contents or table of figures. Read/write Integer.

expression.Level

expression    Required. An expression that returns a HeadingStyle object.

ShowLevel property as it applies to the Subdocument object.

Returns the heading level used to create the subdocument. Read-only Long.

expression.Level

expression    Required. An expression that returns a Subdocument object.

Example

ShowAs it applies to the HeadingStyle object.

This example adds a table of contents at the insertion point in the active document, and then it changes the levels for the heading styles.

ActiveDocument.TablesOfContents.Add _
    Range:=Selection.Range, _
    RightAlignPageNumbers:=True, _
    UseHeadingStyles:=True, _
    UpperHeadingLevel:=1, _
    LowerHeadingLevel:=3, _
    IncludePageNumbers:=True, _
    TableID:=wdTOCFormal
With ActiveDocument.TablesOfContents(1).HeadingStyles
    .Add Style:="Title", Level:=1
    .Add Style:="SubTitle", Level:=2
    .Add Style:="List Bullet", Level:=3
End With
With ActiveDocument.TablesOfContents(1)
    .HeadingStyles(1).Level = 2
    .HeadingStyles(2).Level = 4
    .HeadingStyles(3).Level = 6
End With
				

ShowAs it applies to the Subdocument object.

This example looks through each subdocument in the active document and displays the subdocument's heading level.

i = 1
If ActiveDocument.Subdocuments.Count > = 1 Then
    For each s in ActiveDocument.Subdocuments
        MsgBox "The heading level for SubDoc " & i _
            & " is " & s.Level
        i = i + 1
    Next s
Else
    MsgBox "There are no subdocuments defined."
End If