Add Method (TablesOfContents Collection) Example
This example adds a table of contents at the beginning of the active document. The table of contents is built from paragraphs styled with the Heading 1, Heading 2, and Heading 3 styles or the custom styles myStyle and yourStyle.
Set myRange = ActiveDocument.Range(0, 0)
ActiveDocument.TablesOfContents.Add _
Range:=myRange, _
UseFields:=False, _
UseHeadingStyles:=True, _
LowerHeadingLevel:=3, _
UpperHeadingLevel:=1, _
AddedStyles:="myStyle, yourStyle"