Callback Property

Microsoft Office Visual Basic

Sets the name of the procedure to run from a modeless balloon. Read/write String.

Remarks

The procedure you specify for the Callback property must be written to receive either two or three arguments, depending on what you use the property with. If you use the Callback property with a wizard, you must write the procedure to receive two arguments: a long integer that represents the msoBalloonButtonType value of the button that the user clicked, and a long integer that uniquely identifies the balloon. If you use the Callback property with a modeless balloon, you must write the procedure to receive three arguments: the Balloon object that called the procedure; a long integer that represents the msoBalloonButtonType value of the button the user clicked; and a long integer that uniquely identifies the balloon that called the procedure, as denoted in the balloon’s Private property.

The callback procedure must contain at least one condition under which the Close method is applied to the Balloon object that is passed to it; otherwise, the modeless balloon cannot be dismissed.

If you specify a procedure that is stored in a separate class module, you must include the module name in the value assigned to the Callback property (for example, "Sheet1.MyCallback).

Example

This example displays a balloon that contains a button for each of three printers. Whenever the user clicks one of these buttons, the ProcessPrinter callback procedure is run and the balloon is closed.

Sub selectPrinter()
Set bln = Assistant.NewBalloon
With bln
    .Heading = "Select a Printer."
    .Labels(1).Text = "Network Printer"
    .Labels(2).Text = "Local Printer"
    .Labels(3).Text = "Local Color Printer"
    .BalloonType = msoBalloonTypeButtons
    .Mode = msoModeModeless
    .Callback = "ProcessPrinter"
    .Show
End With
End Sub

Sub ProcessPrinter(bln As Balloon, lbtn As Long, _
 lPriv As Long)
    Assistant.Animation = msoAnimationPrinting
    Select Case lbtn
    Case -1
        ' Insert network printer-specific code.
    Case -2
        ' Insert local printer-specific code.
    Case -3
        ' Insert color printer-specific code.
    End Select
    bln.Close
End Sub