将指定的命令栏作为快捷菜单,在指定坐标或当前光标位置显示。
注意 如果命令栏的 Position 属性没有设置为 msoBarPopup,那么本方法无效。
expression.ShowPopup(x, y)
expression 必需。该表达式返回一个 CommandBar 对象。
x Variant 类型,可选。快捷菜单所在位置的 x 坐标。如果省略此参数,那么将取当前光标位置的 x 坐标。
y Variant 类型,可选。快捷菜单所在位置的 y 坐标。如果省略此参数,那么将取当前光标位置的 y 坐标。
本示例可实现的功能为:创建一个包含两个控件的快捷菜单。ShowPopup 方法用于显示该快捷菜单。
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