Compartilhar via


DocumentBase.ListParagraphs Property

Definition

Gets a ListParagraphs collection that represents all the numbered paragraphs in the document.

public:
 property Microsoft::Office::Interop::Word::ListParagraphs ^ ListParagraphs { Microsoft::Office::Interop::Word::ListParagraphs ^ get(); };
public Microsoft.Office.Interop.Word.ListParagraphs ListParagraphs { get; }
member this.ListParagraphs : Microsoft.Office.Interop.Word.ListParagraphs
Public ReadOnly Property ListParagraphs As ListParagraphs

Property Value

A ListParagraphs collection that represents all the numbered paragraphs in the document.

Examples

The following code example adds text to the first two paragraphs, applies numbering to the paragraphs, and then displays a message that shows the total number of paragraphs that are numbered. To use this example, run it from the ThisDocument class in a document-level project.

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

}
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

Applies to