ShowPopup Method

Microsoft Office Visual Basic

Displays a command bar as a shortcut menu at the specified coordinates or at the current pointer coordinates.

Note  If the Position property of the command bar is not set to msoBarPopup, this method fails.

expression.ShowPopup(x, y)

expression    Required. An expression that returns a CommandBar object.

x    Optional Variant. The x-coordinate for the location of the shortcut menu. If this argument is omitted, the current x-coordinate of the pointer is used.

y    Optional Variant. The y-coordinate for the location of the shortcut menu. If this argument is omitted, the current y-coordinate of the pointer is used.

Example

This example creates a shortcut menu containing two controls. The ShowPopup method is used to make the shortcut menu visible.

Set myBar = CommandBars _
    .Add(Name:="Custom", Position:=msoBarPopup, Temporary:=False)
With myBar
    .Controls.Add Type:=msoControlButton, Id:=3
    .Controls.Add Type:=msoControlComboBox
End With
myBar.ShowPopup