ThisWorkbook里的代码:
Private Sub Workbook_Open()
Call addMenu
End Sub
Sub addMenu() '菜单
Dim Popup(1)
Dim Button(5) As CommandBarControl
Set aa = Application.CommandBars(3).Controls.Add
Set Popup(0) = Application.CommandBars("Worksheet Menu Bar").Controls.Add(Type:=msoControlPopup, temporary:=True)
Popup(0).Caption = "☆工具☆"
Popup(0).Tag = "bb"
Set Button(1) = Popup(0).Controls.Add(Type:=msoControlButton, temporary:=True)
Button(1).Caption = "菜单一"
Button(1).OnAction = ""
Set Button(2) = Popup(0).Controls.Add(Type:=msoControlButton, temporary:=True)
Button(2).Caption = "菜单二"
Button(2).OnAction = ""
Button(2).BeginGroup = True
Set Button(3) = Popup(0).Controls.Add(Type:=msoControlButton, temporary:=True)
Button(3).Caption = "菜单三"
Button(3).OnAction = ""
Button(3).BeginGroup = True
Set Button(4) = Popup(0).Controls.Add(Type:=msoControlButton, temporary:=True)
Button(4).Caption = "菜单四"
Button(4).OnAction = ""
Button(4).BeginGroup = True
Set Button(5) = Popup(0).Controls.Add(Type:=msoControlButton, temporary:=True)
Button(5).Caption = "菜单五"
Button(5).OnAction = ""
Button(5).BeginGroup = True
End Sub