Share via


List Object

SharePoint Designer Developer Reference

Contains information about the List object and the collaboration objects.

Remarks

The List object is a base class that defines the common members used by the different types of lists in Office SharePoint Designer. For example, the collaboration objects—the BasicList, Discussion, DocumentLibrary, and Survey objects—allow information to be shared and exchanged between different users and different Web sites. The List object is a member of the Lists collection.

Use Lists(Index), where Index is either the name of the list or its numeric position within the collection, to return a single List object. The following example displays the names of all lists in the active Web site. If the Web site contains no lists, a message is displayed to the user.

Visual Basic for Applications
Sub ListAllLists()
'Displays the names of all lists in the collection
    Dim lstWebList As List
    Dim strName As String
    'Determine whether any lists exist
    If Not ActiveWeb.Lists Is Nothing Then
        'Cycle through lists
        For Each lstWebList In ActiveWeb.Lists
            'add list names to string
            If strName = "" Then
                strName = lstWebList.Name & vbCr
            Else
                strName = strName & lstWebList.Name & vbCr
            End If
        Next
        'Display names of all lists
        MsgBox "The names of all lists in the current Web site are:" _
               & vbCr & strName
    Else
        'Otherwise display message to user
        MsgBox "The current Web site contains no lists."
    End If
End Sub

Similarly, use the WebFolder object's List property to return the List object associated with the folder.

Use the List object's Fields property to return a collection of ListField objects that define the fields in the current list.

See Also