Propriedade DocumentBase.TablesOfContents

Obtém uma coleção de TablesOfContents que representa os sumários no documento.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (em Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Sintaxe

'Declaração
Public ReadOnly Property TablesOfContents As TablesOfContents
public TablesOfContents TablesOfContents { get; }

Valor de propriedade

Tipo: Microsoft.Office.Interop.Word.TablesOfContents
Uma coleção de TablesOfContents que representa os sumários no documento.

Exemplos

O exemplo de código a seguir adiciona dois parágrafos para o documento e atribui o título 1 e o título 2 estilos a parágrafos.O código então cria um sumário no ponto de inserção que inclui somente os parágrafos estilizados dirigindo 1.Para usar este exemplo, ele execução da classe de ThisDocument em um projeto de um documento nível.

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);
}

Segurança do .NET Framework

Consulte também

Referência

DocumentBase Classe

Namespace Microsoft.Office.Tools.Word