目录

ShowPopup 方法

优质
小牛编辑
118浏览
2023-12-01

全部显示

将指定的命令栏作为快捷菜单,在指定坐标或当前光标位置显示。

注意 如果命令栏的Position 属性没有设置为msoBarPopup,那么本方法无效。

expression.ShowPopup(x,y)

expression 必需。该表达式返回一个CommandBar 对象。

xVariant 类型,可选。快捷菜单所在位置的 x 坐标。如果省略此参数,那么将取当前光标位置的 x 坐标。

yVariant 类型,可选。快捷菜单所在位置的 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