Udostępnij za pośrednictwem


DocumentBase.ListParagraphs Property

Gets a ListParagraphs collection that represents all the numbered paragraphs 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 ListParagraphs As ListParagraphs
    Get
public ListParagraphs ListParagraphs { get; }

Property Value

Type: Microsoft.Office.Interop.Word.ListParagraphs
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 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 Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace