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)

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

Delete

Deletes the specified heading style.


ActiveDocument.TablesOfFigures(1).HeadingStyles(1).Delete

Level

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, _ 
 TableID:=wdTOCFormal 
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

Style

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 =