Document.Subdocuments Property (2007 System)
Gets a Subdocuments collection that represents all the subdocuments in the document.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Subdocuments As Subdocuments
'Usage
Dim instance As Document
Dim value As Subdocuments
value = instance.Subdocuments
[BrowsableAttribute(false)]
public Subdocuments Subdocuments { get; }
[BrowsableAttribute(false)]
public:
property Subdocuments^ Subdocuments {
Subdocuments^ get ();
}
public function get Subdocuments () : Subdocuments
Property Value
Type: 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.
This example is for a document-level customization.
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.