Excel VBA对象模型是否允许访问VBA IDE菜单项的键盘快捷键?

Excel VBA对象模型是否允许访问VBA IDE菜单项的键盘快捷键? (我想在菜单中创build额外的项目,并与select的快捷方式连接)

例如,下面的代码返回“C&”,这意味着当VBE IDE中的“编辑”组处于活动状态时,可以通过键入“l”来访问“清除”项,但也可以通过单击“删除”button来访问“清除”

Debug.Print Application.VBE.CommandBars(1).Controls(2).Controls(6).Caption 

有没有办法在IDE菜单中findpragrammaticaly项目的直接快捷方式(“删除”在上面的情况下)? 我想用新的自定义快捷方式将项目添加到VBA IDE菜单?

 Debug.Print Application.VBE.CommandBars(1).Controls(3).Controls(6).Caption 

返回“&立即窗口”,但您也可以通过直接快捷键“Ctrl + G”访问立即窗口

有没有办法在IDE菜单中findpragrammaticaly项目的直接快捷方式(在上面的例子中是“Delete”)

就在这里。 尝试这个

 Debug.Print Application.VBE.CommandBars(1).Controls(2).Controls(6).ShortcutText 

这会给你Del

评论后续:

在这里输入图像描述

 Dim b As CommandBarButton Set b = Application.VBE.CommandBars(1).Controls(2).Controls(6) Debug.Print b.TooltipText 

收益:

 C&lear (Del) 

同样的,

 Set b = Application.VBE.CommandBars(1).Controls(2).Controls(6) Debug.Print b.TooltipText 

回报

 Export (Ctrl+E)