Lists 集合

         
WebEx
Lists
List

代表当前站点中所有 List 对象的集合。Lists 允许在不同用户和不同站点之间共享和交换信息。

使用 Lists 集合

使用 WebEx 对象的 Lists 属性可以返回站点中的所有列表的集合。使用 Lists.item(index) 可以返回单个 List 对象,其中 index 是列表的名称或其在集合中的位置(用数字显示)。

下列示例显示活动站点中所有列表的名称。如果活动站点不包含任何列表,则向用户显示一条消息。

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 are:" _
               & vbCr & strName
    Else
        'Other wise display message to user
        MsgBox "The current web contains no lists."
    End If

End Sub

使用 Lists.Add 方法可以将新列表添加到 Lists 集合。下列示例将名为 NewShare 的 fpBasicList 类型的新列表添加到活动站点。

Sub NewList()
'Adds a new list to the current web

    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