VBA创设菜单并指定宏代码

fieldset{padding:10px;}

VBA创建菜单并指定宏代码PrivateSubauto_open()Call建立系统工具菜单EndSubSub建立系统工具菜单()DimcmdBarAsCommandBarDimcmdMenuAsCommandBarPopupDimcmdBtnAsCommandBarButtonSetcmdBar=Application.CommandBars(“WorkSheetMenuBar”)’SetcmdBar=Application.CommandBars(1)WithcmdBarSetcmdMenu=.Controls.Add(Type:=msoControlPopup,before:=4,temporary:=True)WithcmdMenu.Caption=”工具箱(&K)”With.Controls.Add(Type:=msoControlButton).Caption=”神奇按钮(&K)”.OnAction=”神奇按钮”.FaceId=185EndWithWith.Controls.Add(Type:=msoControlButton).Caption=”显示所有工作表(D)”.OnAction=”显示所有工作表”.FaceId=12EndWithWith.Controls.Add(Type:=msoControlButton).Caption=”卸载软件(&U)”.OnAction=”卸载”.FaceId=12EndWithEndWithEndWithEndSub以上是excel自动建立菜单的代码,但是现在我想指定我的宏代码,也就是说点击菜单的时候可以运行我的宏代码;因为我目前的代码是通过按钮来执行的,现在我想用上面的VBA代码来连接我的按钮宏代码,应该怎么做?——解决方案——————————————————–

Subauto_open()DimcmdBarAsCommandBarDimcmdMenuAsCommandBarPopupDimcmdBtnAsCommandBarButtonSetcmdBar=Application.CommandBars("WorkSheetMenuBar")WithcmdBarSetcmdMenu=.Controls.Add(Type:=msoControlPopup,before:=4,temporary:=True)WithcmdMenu.Caption="工具箱(&K)"With.Controls.Add(Type:=msoControlButton).Caption="运行自定义模块(&K)".OnAction="自定义模块".FaceId=185EndWithEndWith如果我们想要更多的玫瑰花,就必须种植更多的玫瑰树。

VBA创设菜单并指定宏代码

相关文章:

你感兴趣的文章:

标签云: