Survey Object

SharePoint Designer Developer Reference

Contains information about the Survey object that allows users to vote on issues and share information.

Remarks

Use the Item method of a List object of type ListTypeSurvey, to return a single Survey object.

The following example lists the names of all surveys in the active Web site. If the Web site contains no surveys or the Web site contains no lists, a message is displayed to the user.

Visual Basic for Applications
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 site are:" _
                   & vbCr & strName
        Else
            MsgBox "No survey objects are in the current Web site."
        End If
    Else
        'Otherwise display message to user
        MsgBox "The current Web site contains no lists."
    End If
End Sub

Use the Add method of the Lists collection to create a new list of type ListTypeSurvey. The following example creates a new survey named NewSurvey.

Visual Basic for Applications
Sub NewSurvey()
'Adds a new Survey to the current Web site
    Dim objApp As Application
    Dim objLists As Lists
    Set objApp = 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

See Also