HeadingStyles Collection Object

Word Developer Reference

A collection of HeadingStyle objects that represent the styles used to compile a table of figures or table of contents.

Remarks

Use the HeadingStyles property to return the HeadingStyles collection. The following example displays the number of items in the HeadingStyles collection for the first table of contents in the active document.

Visual Basic for Applications
  MsgBox ActiveDocument.TablesOfContents(1).HeadingStyles.Count

Use the Add method to add a style to the HeadingStyles collection. The following example adds a table of contents at the beginning of the active document and then adds the Title style to the list of styles used to build a table of contents.

Visual Basic for Applications
  Set myToc = ActiveDocument.TablesOfContents.Add _
    (Range:=ActiveDocument.Range(0, 0), UseHeadingStyles:=True, _
     LowerHeadingLevel:=3, UpperHeadingLevel:=1)
myToc.HeadingStyles.Add Style:="Title", Level:=2

Use HeadingStyles(Index), where Index is the index number, to return a single HeadingStyle object. The index number represents the position of the style in the HeadingStyles collection. The following example adds (at the beginning of the active document) a table of figures built from the Title style, and then displays the name of the first style in the HeadingStyles collection.

Visual Basic for Applications
  Set myTOF = ActiveDocument.TablesOfFigures.Add _
    (Range:=ActiveDocument.Range(0, 0), AddedStyles:="Title")
MsgBox myTOF.HeadingStyles(1).Style

See Also