Compartilhar via


TableOfContents.UpperHeadingLevel Property

Word Developer Reference

Returns or sets the starting heading level for a table of contents. Read/write Long.

Syntax

expression.UpperHeadingLevel

expression   Required. A variable that represents a TableOfContents collection.

Remarks

This property corresponds to the starting value used with the \o switch for a Table of Contents (TOC) field. Use the LowerHeadingLevel property to set the ending heading level. For example, to set the TOC field syntax {TOC \o "1-3"}, set the LowerHeadingLevel property to 3 and the UpperHeadingLevel property to 1.

Example

This example formats the first table of contents in the active document to compile all headings that are formatted with either the Heading 2 or Heading 3 style.

Visual Basic for Applications
  If ActiveDocument.TablesOfContents.Count >= 1 Then
    With ActiveDocument.TablesOfContents(1)
        .UseHeadingStyles = True
        .UseFields = False
        .UpperHeadingLevel = 2
        .LowerHeadingLevel = 3
    End With
End If

See Also