Lists Collection Object

Microsoft Word Visual Basic

Lists Collection Object

         
Multiple objects Lists (List)
Multiple objects

A collection of List objects that represent all the lists in the specified document.

Using the Lists Collection

Use the Lists property to return the Lists collection. The following example displays the number of items in each list in the active document.

For Each li In ActiveDocument.Lists
    MsgBox li.CountNumberedItems
Next li

Use Lists(index), where index is the index number, to return a single List object. The following example applies the first list format (excluding None) on the Numbered tab in the Bullets and Numbering dialog box to the second list in the active document.

Set temp1 = ListGalleries(wdNumberGallery).ListTemplates(1)
ActiveDocument.Lists(2).ApplyListTemplate ListTemplate:=temp1

Remarks

When you use a For Each...Next loop to enumerate the Lists collection, the lists in a document are returned in reverse order. The following example counts the items for each list in the active document, from the bottom of the document upward.

For Each li In ActiveDocument.Lists
   MsgBox li.CountNumberedItems
Next li

To add a new list to a document, use the ApplyListTemplate method with the ListFormat object for a specified range.

You can manipulate the individual List objects within a document, but for more precise control you should work with the ListFormat object.

Picture-bulleted lists are not included in the Lists collection.