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 Subdocuments collection that represents all the subdocuments 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 Subdocuments As Subdocuments
public Subdocuments Subdocuments { get; }
Property Value
Type: Microsoft.Office.Interop.Word.Subdocuments
A Subdocuments collection that represents all the subdocuments in the document.
Examples
The following code example applies the Heading 1 style to the first paragraph in the selection and then creates a subdocument for the contents of the selection. The code then displays a message that shows the number of subdocuments in the document. To use this example, run it from the ThisDocument class in a document-level project.
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());
}
.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.