Document.Lists Property (2007 System)

Gets a Lists collection that contains all the formatted lists in the document.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Lists As Lists
'Usage
Dim instance As Document 
Dim value As Lists 

value = instance.Lists
[BrowsableAttribute(false)]
public Lists Lists { get; }
[BrowsableAttribute(false)]
public:
property Lists^ Lists {
    Lists^ get ();
}
public function get Lists () : Lists

Property Value

Type: Lists
A Lists collection that contains all the formatted lists in the document.

Examples

The following code example adds text to the first two paragraphs, applies a list template to the paragraphs, and then displays a message that shows the number of lists in the document.

This example is for a document-level customization.

Private Sub DocumentLists()
    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])
    Dim index As Object = 1

    Dim myTemplate As Word.ListTemplate = Application.ListGalleries( _
        Microsoft.Office.Interop.Word.WdListGalleryType.wdNumberGallery). _
        ListTemplates.Item(index)

    myRange.ListFormat.ApplyListTemplate(myTemplate)

    MessageBox.Show("Total lists in document: " & Me.Lists.Count.ToString())
End Sub
private void DocumentLists()
{
    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);
    object index = 1;

    Word.ListTemplate myTemplate = Application.ListGalleries[Microsoft.Office.Interop.Word.WdListGalleryType.wdNumberGallery].ListTemplates.get_Item(ref index);

    myRange.ListFormat.ApplyListTemplate(myTemplate, 
        ref missing, ref missing, ref missing);

    MessageBox.Show ("Total lists in document: " +
        this.Lists.Count.ToString());

}

.NET Framework Security

See Also

Reference

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace