HeadingStyles Property

Microsoft Word Visual Basic

HeadingStyles Property

       

Returns a HeadingStyles object that represents additional styles used to compile a table of contents or table of figures (styles other than the Heading 1 – Heading 9 styles). Read-only.

Example

This example adds a style to the HeadingStyles collection and then displays the names of all the style in the collection.

Dim hsLoop As HeadingStyle

If ActiveDocument.TablesOfContents.Count >=1 Then
    ActiveDocument.TablesOfContents(1).HeadingStyles.Add _
        Style:="Title", Level:=2
    For Each hsLoop In _
            ActiveDocument.TablesOfContents(1).HeadingStyles
        MsgBox hsLoop.Style
    Next hsLoop
End If

This example adds a style named "Blue" to the HeadingStyles collection in a table of contents for Sales.doc.

With Documents("Sales.doc")
    .Styles.Add Name:="Blue"
    .TablesOfContents(1).UseHeadingStyles = True
    .TablesOfContents(1).HeadingStyles.Add _
        Style:="Blue", Level:=4
End With