This example inserts a TC field with an "A" identifier after the selection in Sales.doc. The first table of contents is then formatted to compile "A" entries.
Documents("Sales.doc").TablesOfContents.MarkEntry _
Range:=Selection.Range, _
Entry:="Hello", TableID:="A"
With Documents("Sales.doc").TablesOfContents(1)
.TableID = "A"
.UseFields = True
.UseHeadingStyles = False
.Update
End With
This example adds a table of figures at the beginning of the active document and then formats the table to compile "B" entries.
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
Set myTOF = ActiveDocument.TablesOfFigures.Add(Range:=myRange)
With myTOF
.UseFields = True
.UseHeadingStyles = False
.TableID = "B"
.Caption = ""
End With