Class TablesOfFigures (Word VBA)

A collection of TableOfFigures objects that represent the tables of figures in a document. To use a TablesOfFigures class variable it first needs to be instantiated, for example


Dim tofs as TablesOfFigures
Set tofs = ActiveDocument.TablesOfFigures

For Each

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


Dim tofsTablesOfFigure As TableOfFigures
For Each tofsTablesOfFigure In ActiveDocument.TablesOfFigures
	
Next tofsTablesOfFigure

Add

Returns a TableOfFigures object that represents a table of figures added to a document.

Add (Range, Caption, IncludeLabel, UseHeadingStyles, UpperHeadingLevel, LowerHeadingLevel, UseFields, TableID, RightAlignPageNumbers, IncludePageNumbers, AddedStyles, UseHyperlinks, HidePageNumbersInWeb)


ActiveDocument.TablesOfFigures.Add Range:=Selection.Range

Arguments

The following argument is required

Range (Range) - The range where you want the table of figures to appear.

Optional arguments

The following arguments are optional

Caption (String) - The label that identifies the items you want to include in the table of figures. Corresponds to the \c switch for a Table of Contents (TOC) field. The default value is "Figure.".

IncludeLabel (String) - True to include the caption label and caption number in the table of figures. The default value is True.

UseHeadingStyles (Boolean) - True to use built-in heading styles to create the table of figures. The default value is False.

UpperHeadingLevel (Long) - The starting heading level for the table of figures, if UseHeadingStyles is set to True. Corresponds to the starting value used with the \o switch for a Table of Contents (TOC) field. The default value is 1.

LowerHeadingLevel (Byte) - The ending heading level for the table of figures, if UseHeadingStyles is set to True. Corresponds to the ending value used with the \o switch for a Table of Contents (TOC) field. The default value is 9.

UseFields (Boolean) - True to use Table of Contents Entry (TC) fields to create the table of figures. Use the MarkEntry method to mark entries you want to include in the table of figures. The default value is False.

TableID (String) - A one-letter identifier that's used to build a table of figures from Table of Contents Entry (TC) fields. Corresponds to the \f switch for a Table of Contents (TOC) field. For example, "i" builds a table of figures for an illustration.

RightAlignPageNumbers (Boolean) - True align page numbers with the right margin in the table of figures. The default value is True.

IncludePageNumbers (Boolean) - True if page numbers are included in the table of figures. The default value is True.

AddedStyles (String) - The string name for additional styles used to compile the table of figures (styles other than the Heading 1 – Heading 9 styles).

UseHyperlinks (Boolean) - True if entries in a table of figures should be formatted as hyperlinks when publishing to the Web. The default value is True.

HidePageNumbersInWeb (Boolean) - True if page numbers in a table of figures should be hidden when publishing to the Web. The default value is True.

Count

Returns a Long that represents the number of tables of figures in the collection.


Dim lngCount As Long
lngCount = ActiveDocument.TablesOfFigures.Count

Format

Returns or sets the formatting for the tables of figures in the specified document. Possible return values are wdTOFCentered - Centered formatting, wdTOFClassic - Classic formatting, wdTOFDistinctive - Distinctive formatting, wdTOFFormal - Formal formatting, wdTOFSimple - Simple formatting, wdTOFTemplate - Template formatting.


ActiveDocument.TablesOfFigures.Format = wdTOFCentered

Item

Returns an individual TableOfFigures 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 tofsTablesOfFigure As TableOfFigures
Set tofsTablesOfFigure = ActiveDocument.TablesOfFigures(Index:=1)

MarkEntry

Inserts a TC (Table of Contents Entry) field after the specified range. The method returns a Field object representing the TC field.

MarkEntry (Range, Entry, EntryAutoText, TableID, Level)


Dim fldMarkEntry As Field
Set fldMarkEntry = ActiveDocument.TablesOfFigures.MarkEntry(Range:=)

Arguments

The following argument is required

Range (Range) - The location of the entry. The TC field is inserted after Range.

Optional arguments

The following arguments are optional

Entry (Table) - The text that appears in the table of contents or table of figures. To indicate a subentry, include the main entry text and the subentry text, separated by a colon (:) (for example, "Introduction:The Product").

EntryAutoText (String) - The AutoText entry name that includes text for the index, table of figures, or table of contents (Entry is ignored).

TableID (String) - A one-letter identifier for the table of figures or table of contents item (for example, "i" for an "illustration").

Level (Long) - A level for the entry in the table of contents or table of figures.