Class HeadingStyles (Word VBA)

A collection of HeadingStyle objects that represent the styles used to compile a table of figures or table of contents. To use a HeadingStyles class variable it first needs to be instantiated, for example


Dim hss as HeadingStyles
Set hss = ActiveDocument.TablesOfFigures(1).HeadingStyles

For Each

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


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

Add

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.

Add (Style, Level)


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

Arguments

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.

Count

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


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

Item

Returns an individual HeadingStyle object in a collection.

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)