CommandBarEvents Property

Applies To

Events object.

Description

Returns the CommandBarEvents object. Read-only.

Settings

The setting for the argument you pass to the CommandBarEvents property is:

Argument

Description

vbcontrol

Must be an object of type CommandBarControl.


Remarks

Use the CommandBarEvents property to return an event source object that triggers an event when a command bar button is clicked. The argument passed to the CommandBarEvents property is the command bar control for which the Click event will be triggered.

See Also

Click event, CommandBarEvents object, CommandBars collection, ReferencesEvents property.

Example

The following example uses code including the CommandBarEvents property to support any code to handle a mouse click on a command bar.

Private WithEvents ce As CommandBarEvents

Sub Test()
    Dim c As CommandBarControl
    Set c = Application.VBE.CommandBars("Tools").Controls(1)
    Set ce = Application.VBE.Events.CommandBarEvents(c)
End Sub

Private Sub ce_Click(ByVal CommandBarControl As Object, Handled As Boolean, CancelDefault As Boolean)
    ' Put event-handling code here.
End Sub