自定义功能区的VBA弹出菜单

时间:2017-04-26 04:17:15

标签: vba menu popup

我有以下VBA代码为excel中的自定义功能区中的按钮创建弹出菜单,但是,当我单击自定义功能区中的按钮时,出现“无效的过程调用或参数”错误。

Sub ScenarioDropDown(control As IRibbonControl)

Dim PopupMenu As CommandBar, Menu(2) As CommandBarControl

Application.ScreenUpdating = False
    Application.CommandBars("ScenarioDrop").Delete

    Set PopupMenu = CommandBars.Add("ScenarioDrop", msoBarPopup, , True)
    Set Menu(1) = PopupMenu.Controls.Add(Type:=msoControlButton, Temporary:=True)
    Set Menu(2) = PopupMenu.Controls.Add(Type:=msoControlButton, Temporary:=True)
    Menu(1).Caption = "Deterministic Sensitivity Analyses Inputs"
    Menu(1).OnAction = "GoToDSAInputs"
    Menu(2).Caption = "Probabilistic Sensitivity Analysis Inputs"
    Menu(2).OnAction = "GoToPSAInputs"
    Application.ScreenUpdating = True
CommandBars("ScenarioDrop").ShowPopup
End Sub

0 个答案:

没有答案