DocumentBase.Subdocuments 屬性
取得 Subdocuments 集合,表示文件中的所有子文件。
命名空間: Microsoft.Office.Tools.Word
組件: Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)
語法
'宣告
Public ReadOnly Property Subdocuments As Subdocuments
Get
public Subdocuments Subdocuments { get; }
屬性值
型別:Microsoft.Office.Interop.Word.Subdocuments
Subdocuments 集合,表示文件中的所有子文件。
範例
下列程式碼範例會將標題 1 樣式套用至選取範圍的第一個段落,然後針對選取範圍的內容建立子文件。 接著,程式碼會顯示訊息,說明文件中的子文件數目。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。