Survey 对象

         
Survey
多个对象

包含关于 Microsoft FrontPage Survey 对象的信息,该对象允许用户对问题提出建议以及共享信息。

使用 Survey 对象

使用 Lists.Item(index) 可以返回单个 Survey 对象,其中 indexfpListTypeSurvey 类型的 List 对象的名称或位置序号。

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

Sub ListAllSurveys()
'Displays the names of all survey objects 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
    If Not ActiveWeb.Lists Is Nothing Then
        'Cycle through lists
        For Each lstWebList In ActiveWeb.Lists
            If lstWebList.Type = fpListTypeSurvey Then
                'Set boolen flag to found
                blnFound = True
                'add list names to string
                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 survey objects
            MsgBox "The names of all survey objects in the current web are:" _
                   & vbCr & strName
        Else
            MsgBox "There are no survey objects 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 方法可以创建 fpListTypeSurvey 类型的新列表。下列示例创建名为 NewSurvey 的新调查。

Sub NewSurvey()
'Adds a new Survey to the current web

    Dim objApp As FrontPage.Application
    Dim objLists As Lists

    Set objApp = FrontPage.Application
    Set objLists = objApp.ActiveWeb.Lists
    'Add new survey
    objLists.Add Name:="NewSurvey", _
                 ListType:=fpListTypeSurvey, _
                 Description:="New Survey"

    'Display message to user
    MsgBox "A new survey was added to the Lists collection."

End Sub