Partager via


DocumentBase.ListParagraphs, propriété

Obtient une collection ListParagraphs qui représente tous les paragraphes numérotés dans le document.

Espace de noms :  Microsoft.Office.Tools.Word
Assembly :  Microsoft.Office.Tools.Word.v4.0.Utilities (dans Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Syntaxe

'Déclaration
Public ReadOnly Property ListParagraphs As ListParagraphs
public ListParagraphs ListParagraphs { get; }

Valeur de propriété

Type : Microsoft.Office.Interop.Word.ListParagraphs
Collection ListParagraphs qui représente tous les paragraphes numérotés dans le document.

Exemples

L'exemple de code suivant ajoute le texte aux deux premiers paragraphes, applique la numérotation aux paragraphes puis affiche un message qui montre le nombre total des paragraphes numérotés. Pour utiliser cet exemple, exécutez-le à partir de la classe ThisDocument dans un projet au niveau du document.

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

}

Sécurité .NET Framework

Voir aussi

Référence

DocumentBase Classe

Microsoft.Office.Tools.Word, espace de noms