Creating and Modifying Balloons

See Also         Specifics

Use the Office Assistant balloon to provide information to your user. The information inside the balloon can be a simple message, a request for more information, or a list of choices for the user. Office Assistant balloons are created, displayed, closed, and changed at run time.

The following table contains the most commonly used properties and methods for changing either the appearance or function of a new or existing balloon. Balloons are displayed, or refreshed, when the Show method is used; therefore, changes you make to a balloon will appear the next time the Show method is used.

Property or method Description
Heading Specifies the bold text appearing at the top of the Office Assistant balloon.
Text Specifies the text appearing in the body of the Office Assistant balloon. This text appears after the heading but before any check boxes, labels, or buttons.
Labels Returns the collection of labels in the balloon. The format of the labels is determined by the BalloonType property. Labels appear after the balloon text. The list of labels can be numbered or bulleted, or a list of buttons. Unlike check boxes, the user's choice is registered as soon as a button is clicked.
CheckBoxes Returns the collection of check boxes in the balloon. The user clicks the check box and clicks the appropriate button at the bottom of the balloon (for example, OK or Next) to register his or her choice.
Close Closes and dismisses a modeless balloon, but doesn't release the object variable. The object variable assigned to the balloon is still valid — you can display it again, or you can modify it and display it later. You can use this method only on modeless balloons.
Show Displays the balloon, and all the objects inside it, to the user. Use this method only for Balloon objects; use the Visible property for the Assistant object.

The following example creates a balloon that helps the user select a printer. The example provides a check box option for users who want to skip the information in the balloon.

Set bln = Assistant.NewBalloon
With bln
    .Heading = "Instructions for Choosing a Printer."
    .Text = "Click OK when you've chosen a printer."
    lblTxt = "From the File menu, choose Print."
    .Labels(1).Text = lblTxt
    .Labels(2).Text = "Click Setup."
    .Labels(3).Text = "Select the name of the printer."
    .CheckBoxes(1).Text = "Skip this information."
    .BalloonType = msoBalloonTypeNumbers
    .Mode = msoModeModal
    .Button = msoButtonSetOK
    .Show
End With

Creating balloons

To create a new balloon, use the NewBalloon property of the Assistant object. The new balloon will be blank. Use the Heading property to add a heading, and use the Text property to add text to the body of the balloon and then add controls, if needed. Finally, use the Show method to display the balloon. The Show method will show the balloon as it appears at that moment; therefore, it's important to use this method after setting all the other properties of the balloon. The following example creates a new balloon, sets the heading and body text, and creates three check box controls that the user can select.

With Assistant.NewBalloon
    .Button = msoButtonSetOkCancel
    .Heading = "Regional Sales Data"
    .Text = "Select a region"
    For i = 1 To 3
        .CheckBoxes(i).Text = "Region " & i
    Next
    .Show
End With

Managing multiple balloons

The Office Assistant does not have a Balloons collection. To manage multiple balloons, you can set a separate object variable for each balloon you create and refer to the variable as needed. Or you can create an array of Balloon object variables and assign a balloon to each one. The following example creates an array and adds three blank Balloon objects to the array.

Dim myBalloonArray(3) As Balloon

With Assistant
    For i = 1 To 3
        Set myBalloonArray(i) = .NewBalloon
    Next
End With