霰粒肿手术:Excel 可任意扩展的菜单及功能代码
来源:百度文库 编辑:九乡新闻网 时间:2024/05/17 01:43:49
[分享] 可任意扩展的菜单及功能代码 [复制链接]
.pcb{margin-right:0} '*************************************************''* 可任意扩展的菜单及功能代码 *'
'* ------------------------------- *'
'* 日期:2009-10-1 *'
'*************************************************'
Sub AddCustomMenu() '建立自定义菜单主调程序
On Error Resume Next
Application.ScreenUpdating = False
For i = Application.MenuBars(xlWorksheet).Menus.Count To 1 Step -1
Application.MenuBars(xlWorksheet).Menus.Item(i).Delete
Next i
With Application
.CommandBars("Standard").Visible = False
.CommandBars("Formatting").Visible = False
.CommandBars("Stop Recording").Visible = False
.CommandBars("toolbar list").Enabled = False
.CommandBars.DisableAskAQuestionDropdown = True
.DisplayFormulaBar = False
End With
Dim cmb As CommandBarControl
Set cmb = AddCustomCommandBarPopup("主菜单1(&字母)") '设置主菜单
AddCustomCommandBarItem cmb, "下级菜单1(&字母)", "宏1", False, True, 0, "" '设置下级菜单并调用宏1
Set cmb = Application.CommandBars("Worksheet Menu Bar").Controls("主菜单1(&字母)")
AddCustomCommandBarItem cmb, "下级菜单1(&字母)", "", False, True, 0, "" '与"下级菜单1(&字母)"菜单同级
Set cmb = AddCustomCommandBarPopup("主菜单2(&字母)") '设置主菜单
AddCustomCommandBarItem cmb, "下级菜单2", "宏2", False, True, 0, "" '设置下级菜单并调用宏2
'可任意扩展菜单项
'……
End Sub
Function AddCustomCommandBarPopup(Caption As String) As CommandBarControl '添加主菜单项
Dim cmb As CommandBarControl
Set cmb = Application.CommandBars("Worksheet Menu Bar").Controls.Add(msoControlPopup)
cmb.Caption = Caption
cmb.Visible = True
Set AddCustomCommandBarPopup = cmb
End Function
Sub AddCustomCommandBarItem(cmbc As CommandBarControl, _
Caption As String, Macro As String, NewGroup As Boolean, Enable As Boolean, FId As Integer, ShortT As String) '添加菜单选项
Dim cbb As CommandBarButton
Set cbb = cmbc.Controls.Add(msoControlButton)
cbb.Caption = Caption
If FId > 0 Then cbb.FaceId = FId
If ShortT <> "" Then cbb.ShortcutText = ShortT
cbb.OnAction = Macro
cbb.BeginGroup = NewGroup
cbb.Enabled = Enable
End Sub
Function AddCustomCommandBarPopup2(cmbc As CommandBarControl, Caption As String) As CommandBarControl '添加子菜单项
Dim cmb As CommandBarControl
Set cmb = cmbc.Controls.Add(msoControlPopup)
cmb.Caption = Caption
cmb.Visible = True
Set AddCustomCommandBarPopup2 = cmb
End Function
Excel 可任意扩展的菜单及功能代码
让你的U盘扩展功能
PowerPoint功能扩展的几个常用方法
定位任意位置的代码L
右键菜单终极锤炼术_右键级联菜单的扩展 - 6
【FireFox】制作可自动升级的扩展
9种可扩展身体的动物
尼泊尔 可任意挥霍时间的天堂
通达信功能扩展1
可装饰博客的精美动画及代码
可装饰博客的精美动画及代码(13)
可装饰博客的精美动画及代码
可装饰博客的精美动画及代码
可装饰博客的精美动画及代码1
excel 有用的evba代码
Routing\CCNP PPT - BSCI 可扩展的网络设计
Excel 二级下拉菜单的3种方法(转)
可填写倒计时器及代码
端口扩展器降低折叠手机的成本及尺寸
火狐(Firefox)优化及我使用的一些扩展介绍
开启Excel的自动保存功能 (怡爽 的分类目录 [Excel])
Excel表格中鲜为人知的“照相机”功能
Excel中鲜为人知的“照相机”功能2
Excel表格中鲜为人知的“照相机”功能