BasicList 对象

         
BasicList
多个对象

包含 Microsoft FrontPage 中所用的基本列表类型的有关信息。BasicList 对象使用户可以在站点间共享信息以及对信息进行分类。

使用 BasicList 对象

使用 Lists.item(index) 返回单个 Basic List 对象,其中 index 是基本列表的名称或其在集合中的位置(用数字表示)。下列示例显示活动站点中的所有基本列表的名称。如果站点没有包含列表,则向用户显示一条消息。

Sub ListAllLists()
'Displays the names of all basic lists in the collection

    Dim lstWebList As List
    Dim strName As String
    Dim blnFound As Boolean

    'Set found flag to false
    blnFound = False
    'Check if any lists exist and, if so cycle through them
    If Not ActiveWeb.Lists Is Nothing Then
        For Each lstWebList In ActiveWeb.Lists
            If lstWebList.Type = fpListTypeBasicList Then
                'Set boolean flag to found and names to string
                blnFound = True
                If strName = "" Then
                    strName = lstWebList.Name & vbCr
                Else
                    strName = strName & lstWebList.Name & vbCr
                End If
            End If
        Next
        If blnFound = True Then
            'Display names of all basic lists
            MsgBox "The names of all basic lists in the current web are:" _
                   & vbCr & strName
        Else
            MsgBox "There are no basic lists in the current web."
        End If
    Else
        'Otherwise display message to user
        MsgBox "The current web contains no lists."
    End If

End Sub

使用 Lists 集合的 Add 方法可以创建 fpListTypeBasicList 类型的新列表。下列示例创建名为 NewShare 的新列表。

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 and displays a message to the user.
    objLists.Add Name:="NewShare", _
                 ListType:=fpListTypeBasicList, _
                 Description:="List of Shared files"

    MsgBox "A new list was added to the Lists collection."

End Sub

?