Compartilhar via


Lists Collection Object

Word Developer Reference

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

Remarks

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

Visual Basic for Applications
  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.

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

When you use a For Each 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.

Visual Basic for Applications
  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.

Bb212026.vs_note(en-us,office.12).gif  Note
Picture-bulleted lists are not included in the Lists collection.

See Also