Class HeadingStyle (Word VBA)

The class HeadingStyle represents a style used to build a table of contents or figures. The HeadingStyle object is a member of the HeadingStyles collection.


To use a HeadingStyle class variable it first needs to be instantiated, for example

Dim hse as HeadingStyle
Set hse = ActiveDocument.TablesOfFigures(1).HeadingStyles(Index:=1)

The following procedures can be used to set variables of type HeadingStyle: HeadingStyles.Add, HeadingStyles.Item, TableOfContents.HeadingStyles and TableOfFigures.HeadingStyles

For Each

Here is an example of processing the HeadingStyle items in a collection.

Dim hse As HeadingStyle
For Each hse In ActiveDocument.TablesOfFigures(1).HeadingStyles
Next hse


Deletes the specified heading style.



Returns or sets the level for the heading style in a table of contents or table of figures.

ActiveDocument.TablesOfContents.Add _ 
 Range:=Selection.Range, _ 
 RightAlignPageNumbers:=True, _ 
 UseHeadingStyles:=True, _ 
 UpperHeadingLevel:=1, _ 
 LowerHeadingLevel:=3, _ 
 IncludePageNumbers:=True, _ 
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


Returns an object that represents the parent object of the specified HeadingStyle object.

Dim objParent As Object
Set objParent = ActiveDocument.TablesOfFigures(1).HeadingStyles(1).Parent


Returns or sets the style for a heading. Read/write Variant.

To set this property, specify the local name of the style, an integer, a WdBuiltinStyle constant, or an object that represents the style.

ActiveDocument.TablesOfFigures(1).HeadingStyles(1).Style =


Returns a HeadingStyle object that represents a new heading style added 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)

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


The following arguments are required:

Style (Style) - 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 (Integer) - A number that represents the level of the heading.


Returns a Long that represents the number of heading styles in the collection.

Dim lngCount As Long
lngCount = ActiveDocument.TablesOfFigures(1).HeadingStyles.Count


Returns an individual HeadingStyle object in a collection.

Syntax : expression.Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position of the individual object.

Dim hse As HeadingStyle
Set hse = ActiveDocument.TablesOfFigures(1).HeadingStyles(Index:=1)


Returns an object that represents the parent object of the specified HeadingStyles object.

Dim objParent As Object
Set objParent = ActiveDocument.TablesOfFigures(1).HeadingStyles.Parent