Add Method (HeadingStyles Collection)

Applies To

HeadingStyles collection object.

Description

Adds a new heading style to a document. The new heading style will be included whenever you compile a table of contents or table of figures.

Syntax

expression.Add(Style, Level)

expression Required. An expression that returns a HeadingStyles object.

Style Required Variant. The style you want to add. You can specify this argument by using either the string name for the style or a Style object.

Level Required Integer. A number that represents the level of the heading.

See Also

Add method (Styles collection), HeadingStyles property, TableOfContents object, TableOfFigures object.

Example

This 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.

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