Class TableOfContents (Word VBA)
The class TableOfContents represents a single table of contents in a document. The TableOfContents object is a member of the TablesOfContents collection. The TablesOfContents collection includes all the tables of contents in a document.
Dim tocs as TableOfContents
Set tocs = ActiveDocument.TablesOfContents(Index:=1)
For Each
Here is an example of processing the TableOfContents items in a collection.
Dim hs As HeadingStyle
If ActiveDocument.TablesOfContents.Count >=1 Then
ActiveDocument.TablesOfContents(1).HeadingStyles.Add Style:="Title", Level:=2
For Each hs In _
ActiveDocument.TablesOfContents(1).HeadingStyles
MsgBox hs.Style
Next hs
End If
Methods
Delete - Deletes the specified table of contents.
Update - Updates the entries shown in a table of contents.
UpdatePageNumbers - Updates the page numbers for items in the specified table of contents.
Properties
HeadingStyles returns a HeadingStyles object that represents additional styles used to compile a table of contents or table of figures (styles other than the Heading 1 - Heading 9 styles).
HidePageNumbersInWeb returns or sets whether page numbers in a table of contents or a table of figures should be hidden when publishing to the Web.
IncludePageNumbers true if page numbers are included in the table of contents.
LowerHeadingLevel returns or sets the ending heading level for a table of contents or table of figures.
Range returns a Range object that represents the portion of a document that is contained within the specified table of contents.
RightAlignPageNumbers true if page numbers are aligned with the right margin in a table of contents.
TabLeader returns or sets the character between entries and their page numbers in an index, table of authorities, table of contents, or table of figures.
TableID returns or sets a one-letter identifier that's used to build a table of contents from TOC fields.
UpperHeadingLevel returns or sets the starting heading level for a table of contents.
UseFields true if Table of Contents Entry (TC) fields are used to create a table of contents or a table of figures.
UseHeadingStyles true if built-in heading styles are used to create a table of contents.
UseHyperlinks returns or sets whether entries in a table of contents should be formatted as hyperlinks when publishing to the Web.
Related Classes
HeadingStyles - A collection of HeadingStyle objects that represent the styles used to compile a table of figures or table of contents.
Range - Represents a contiguous area in a document. Each Range object is defined by a starting and ending character position.