Compartilhar via


Document.Lists Property

Word Developer Reference

Returns a Lists collection that contains all the formatted lists in the specified document. Read-only.

Syntax

expression.Lists

expression   A variable that represents a Document object.

Remarks

For information about returning a single member of a collection, see Returning an Object from a Collection.

Example

This example formats the selection as a numbered list. The example then displays a message box that reports the number of lists in the active document.

Visual Basic for Applications
  Selection.Range.ListFormat.ApplyListTemplate _
    ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(2)
MsgBox "This document has " & ActiveDocument.Lists.Count _
    & " lists."

This example formats the third list in the active document with the default bulleted list format. If the list is already formatted with a bulleted list format, the example removes the formatting.

Visual Basic for Applications
  If ActiveDocument.Lists.Count >= 3 Then
    ActiveDocument.Lists(3).Range.ListFormat.ApplyBulletDefault
End If

This example displays a message box that reports the number of items in each list in MyLetter.doc.

Visual Basic for Applications
  Set myDoc = Documents("MyLetter.doc")
i = myDoc.Lists.Count
For each li in myDoc.Lists
    Msgbox "List " & i & " has " & li.CountNumberedItems _
        & " items."
    i = i - 1
Next li

See Also