DocumentBase.ListParagraphs 屬性

取得 ListParagraphs 集合,表示在文件中的所有編號段落。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public ReadOnly Property ListParagraphs As ListParagraphs
    Get
public ListParagraphs ListParagraphs { get; }

屬性值

型別:Microsoft.Office.Interop.Word.ListParagraphs
ListParagraphs 集合,表示在文件中的所有編號段落。

範例

下列程式碼範例會將文字加入至前兩個段落中、套用編號至段落,然後顯示訊息說明編號段落的總數。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentListParagraphs()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.InsertParagraphAfter()

    Me.Paragraphs(1).Range.Text = "This is the first paragraph."
    Me.Paragraphs(2).Range.Text = "This is the second paragraph."

    Dim Start As Object = Me.Paragraphs(1).Range.Start
    Dim [End] As Object = Me.Paragraphs(2).Range.End
    Dim myRange As Word.Range = Me.Range(Start, [End])

    myRange.ListFormat.ApplyNumberDefault()
    MessageBox.Show("Total numbered paragraphs: " & Me.ListParagraphs.Count)
End Sub
private void DocumentListParagraphs()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.InsertParagraphAfter();


    this.Paragraphs[1].Range.Text = "This is the first paragraph.";
    this.Paragraphs[2].Range.Text = "This is the second paragraph.";

    object Start = this.Paragraphs[1].Range.Start;
    object End = this.Paragraphs[2].Range.End;
    Word.Range myRange = this.Range(ref Start,
        ref End);

    myRange.ListFormat.ApplyNumberDefault(ref missing);
    MessageBox.Show("Total numbered paragraphs: " +
        this.ListParagraphs.Count);

}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間