|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
试试看:- Private Sub Workbook_Open()
- Dim Hngcbb As CommandBarPopup, NewMenu As CommandBarPopup, mp As CommandBarButton
- On Error Resume Next
- Application.CommandBars("Worksheet menu bar").Controls("我的报表(&G)").Delete
- Set Hngcbb = Application.CommandBars(1).Controls.Add(Type:=msoControlPopup, _
- Before:=Application.CommandBars(1).Controls("帮助(&H)").Index, Temporary:=True) '添加Excel菜单项,我的报表
- With Hngcbb
- .Caption = "我的报表(&G)"
- .Visible = True
- End With
-
- '添加第一个子菜单,我的报表
- Set NewMenu = Hngcbb.Controls.Add(Type:=msoControlPopup, Temporary:=True)
- With NewMenu
- .Caption = "我的报表(&C)"
- .BeginGroup = True
- End With
- '以下加菜单项
- Set mp = NewMenu.Controls.Add(msoControlButton)
- With mp
- .Caption = "最后一级"
- .OnAction = "ThisWorkbook.Macro1"
- .FaceId = 422
- End With
- Set Hngcbb = Nothing
- Set NewMenu = Nothing
- Set mp = Nothing
- End Sub
- Sub Macro1()
- MsgBox "这是最后一级测试"
- End Sub
复制代码 |
|