Lists Collection






Represents the collection of all List objects in the current Web site. Lists allow information to be shared and exchanged between different users and different Web sites.
This object is supported only by Web pages or sites that are based on Microsoft SharePoint Services.
Using the Lists collection
Use the Lists property of the WebEx object to return the collection of all lists in the Web site. Use Lists.item (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 active Web site does not contain any lists, a message is displayed to the user.
Sub ListAllLists()
'Displays the names of all lists in the collection
Dim lstWebList As List
Dim strName As String
'Check if 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
'Other wise display message to user
MsgBox "The current Web site contains no lists."
End If
End Sub
Use the Lists.Add method to add a new list to the Lists collection. The following example adds a new list of type fpBasicList called NewShare to the active Web site.
Sub NewList()
'Adds a new list to the current Web site
Dim objApp As FrontPage.Application
Dim objLists As Lists
Set objApp = FrontPage.Application
Set objLists = objApp.ActiveWeb.Lists
'Add new list
objLists.Add Name:="NewShare", _
ListType:=fpListTypeBasicList, _
Description:="List of Shared files"
'Display message to user
MsgBox "A new list was added to the Lists collection."
End Sub