Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Gets a TablesOfContents collection that represents the tables of contents in the document.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
Syntax
'Declaration
Public ReadOnly Property TablesOfContents As TablesOfContents
public TablesOfContents TablesOfContents { get; }
Property Value
Type: Microsoft.Office.Interop.Word.TablesOfContents
A TablesOfContents collection that represents the tables of contents in the document.
Examples
The following code example adds two paragraphs to the document and assigns the Heading 1 and Heading 2 styles to the paragraphs. The code then creates a table of contents at the insertion point that includes only paragraphs styled Heading 1. To use this example, run it from the ThisDocument class in a document-level project.
Private Sub DocumentTablesOfContents()
Me.Paragraphs(1).Range.InsertParagraphBefore()
Me.Paragraphs(1).Range.InsertParagraphBefore()
Me.Paragraphs(1).Range.Text = "Heading 1"
Me.Paragraphs(2).Range.Text = "Heading 2"
Dim Style1 As Object = Word.WdBuiltinStyle.wdStyleHeading1
Me.Paragraphs(1).Style = Style1
Dim Style2 As Object = Word.WdBuiltinStyle.wdStyleHeading2
Me.Paragraphs(2).Style = Style2
Dim HeadingLevel As Object = 1
Me.TablesOfContents.Add(Me.Application.Selection.Range, , HeadingLevel, _
HeadingLevel)
End Sub
private void DocumentTablesOfContents()
{
this.Paragraphs[1].Range.InsertParagraphBefore();
this.Paragraphs[1].Range.InsertParagraphBefore();
this.Paragraphs[1].Range.Text = "Heading 1";
this.Paragraphs[2].Range.Text = "Heading 2";
object Style1 = Word.WdBuiltinStyle.wdStyleHeading1;
this.Paragraphs[1].set_Style(ref Style1);
object Style2 = Word.WdBuiltinStyle.wdStyleHeading2;
this.Paragraphs[2].set_Style(ref Style2);
object HeadingLevel = 1;
this.TablesOfContents.Add(this.Application.Selection.Range,
ref missing, ref HeadingLevel, ref HeadingLevel,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.