Propriedade DocumentBase.Subdocuments

Obtém uma coleção de Subdocuments que representa todos os subdocuments 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 Subdocuments As Subdocuments
public Subdocuments Subdocuments { get; }

Valor de propriedade

Tipo: Microsoft.Office.Interop.Word.Subdocuments
Uma coleção de Subdocuments que representa todos os subdocuments no documento.

Exemplos

O exemplo de código a seguir aplica o estilo de título 1 para o primeiro parágrafo na seleção e então cria um subdocument para o conteúdo de seleção.O código então exibe uma mensagem que mostra o número de subdocuments no documento.Para usar este exemplo, ele execução da classe de ThisDocument em um projeto de um documento nível.

Private Sub DocumentSubdocuments()
    Dim style As Object = Word.WdBuiltinStyle.wdStyleHeading1

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Text = "This is sample text."
    Dim currentRange As Word.Range = Me.Paragraphs(1).Range
    currentRange.Select()
    Me.Application.Selection.Paragraphs(1).Style = style

    Me.Subdocuments.Expanded = True
    Me.Subdocuments.AddFromRange(Application.Selection.Range)

    MessageBox.Show("Total subdocuments: " & Me.Subdocuments.Count.ToString())
End Sub 
private void DocumentSubdocuments()
{
    object style = Word.WdBuiltinStyle.wdStyleHeading1;

    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Text = "This is sample text.";
    Word.Range currentRange = this.Paragraphs[1].Range;
    currentRange.Select();
    this.Application.Selection.Paragraphs[1].set_Style(ref style);

    this.Subdocuments.Expanded = true;
    this.Subdocuments.AddFromRange(Application.Selection.Range);

    MessageBox.Show("Total subdocuments: " + this.Subdocuments.Count.ToString());
}

Segurança do .NET Framework

Consulte também

Referência

DocumentBase Classe

Namespace Microsoft.Office.Tools.Word