|
Sub mb()
'
MsgBox ("a")
'
End Sub
------------
Sub MyOwnMenu()
Dim myCommandBar As CommandBar
Dim myCommandBar_Menu1 As CommandBarControl
Dim myCommandBar_MenuItem1 As CommandBarControl
'这一步是新建“工具栏”
Set myCommandBar = Application.CommandBars.Add("Serena", msoBarTop, False, False)
'这一步是新建“弹出菜单”
Set myCommandBar_Menu1 = myCommandBar.Controls.Add(msoControlPopup, , , , True)
'这三行是为“弹出菜单”起个名
With myCommandBar_Menu1
.Caption = "菜单1"
End With
'这一步是新建“菜单项”
Set myCommandBar_MenuItem1 = myCommandBar_Menu1.Controls.Add(msoControlButton, 1, , , True)
'这三行是为“菜单项”起名,并指定宏
With myCommandBar_MenuItem1
.Caption = "动作1"
.OnAction = "mb"
End With
----------
问题1:点击“动作1“,弹出错误!
问题2:自己建的工具栏如何用VBA使它出现在EXCEL界面?
谢谢高人指点!!!
|
|