Microsoft Office Assistant Example

The following function creates a custom balloon for the Office Assistant and determines how the user responded to the balloon:

Function AssistantBalloon(Optional varCheck As Variant, Optional varLabel As Variant)
    Dim bch As BalloonCheckbox
    Dim intI As Integer
    Dim intReturn As Integer
    Dim strCheck(5) As String
    Dim strList As String

    ' Create new balloon.
    Set bal = Assistant.NewBalloon
    ' Specify balloon type.
    bal.BalloonType = msoBalloonTypeButtons
    ' Specify that balloon is modal.
    bal.Mode = msoModeModal

    ' Make Assistant visible.
    If Assistant.Visible = False Then Assistant.Visible = True
    ' Check if first argument has been passed.
    If Not IsMissing(varCheck) Then
        ' If too large, set to maximum number of check boxes (5).
        If varCheck > 6 Then
            varCheck = 5
        End If
        ' Set text property to alphabet character.
        For intI = 1 To varCheck
            bal.Checkboxes(intI).Text = Chr(64 + intI)
        Next intI
    End If

    If Not IsMissing(varLabel) Then
        ' If too large, set to maximum number of labels (5).
        If varLabel > 6 Then
            varLabel = 5
        End If
        For intI = 1 To varLabel
            ' Set text property to alphabet character.
            bal.Labels(intI).Text = Chr(64 + intI)
        Next intI
    End If
    ' Store return value.
    intReturn = bal.Show

    intI = 0
    ' Determine which check boxes were checked, if any.
    For Each bch In bal.Checkboxes
        If bch.Checked = True Then
            strCheck(intI) = bch.Text
            strList = strList & "'" & strCheck(intI) & "'" & Chr(32)
        End If
        intI = intI + 1
    Next
    If Len(strList) <> 0 Then
        MsgBox "You selected checkboxes " & strList & "."
    End If
    ' Determine which label was selected, if any.
    If intReturn > 0 Then
        MsgBox "You selected label " & bal.Labels(intReturn).Text & "."
    End If
End Function

You could call this function from the Debug window as follows:

? AssistantBalloon(4, 5)