Proprietà DocumentBase.Subdocuments

Ottiene un insieme di Subdocuments che rappresenta tutti i documenti secondari del documento.

Spazio dei nomi:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Sintassi

'Dichiarazione
Public ReadOnly Property Subdocuments As Subdocuments
    Get
public Subdocuments Subdocuments { get; }

Valore proprietà

Tipo: Microsoft.Office.Interop.Word.Subdocuments
Insieme di Subdocuments che rappresenta tutti i documenti secondari del documento.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato come applicare lo stile Intestazione 1 al primo paragrafo della selezione e come creare un documento secondario per il contenuto della selezione. Nell'esempio viene quindi illustrato come visualizzare un messaggio contenente il numero di documenti secondari del documento. Per utilizzare questo esempio, eseguirlo dalla classe ThisDocument in un progetto a livello di documento.

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

DocumentBase Classe

Spazio dei nomi Microsoft.Office.Tools.Word