|
谢谢分享 Option Explicit
Sub Auto_Open()
生成自定义菜单
End Sub
Sub Auto_Close()
删除自定义菜单
End Sub
Option Explicit
Dim MenuBar As CommandBarPopup
Dim MenuItem As Object
Dim SubMenuItem As Object
Sub 删除自定义菜单()
On Error Resume Next
Dim ctl As Object
For Each ctl In CommandBars(1).Controls
If ctl.Tag Like "*自定义*" Then ctl.Delete
Next
End Sub
Sub 生成自定义菜单()
On Error Resume Next
Dim cb As CommandBar
Call 删除自定义菜单
Call 主菜单("客户管理")
Call 子菜单2("客户入院登记", "床位表管理")
Call 子菜单2("客户出院办理", "客户出院办理")
Call 子菜单1("客户结算")
Call 子菜单11("结算", "客户结算")
Call 子菜单11("打印", "打印结算")
Call 主菜单("日常管理")
Call 子菜单1("填写医嘱单")
Call 子菜单11("长嘱单", "医嘱单_长期")
Call 子菜单11("临嘱单", "医嘱单_临时")
Call 子菜单11("保存医嘱单", "医嘱单_保存")
Call 子菜单1("执行医嘱单")
Call 子菜单11("今日已执行医嘱单", "医嘱单_今日已执行")
Call 子菜单11("今日未执行医嘱单", "医嘱单_今日未执行")
Call 子菜单11("打印医嘱单", "医嘱单_打印")
Call 子菜单11("停止执行医嘱", "医嘱单_执行")
Call 子菜单2("药品入库", "药品入库")
Call 主菜单("报表管理")
Call 子菜单2("客户费用明细表", "客户结算")
Call 子菜单2("客户自备药明细表", "客户结算")
Call 子菜单2("药品库存明细表", "药品库存明细表")
Call 主菜单("数据维护")
Call 子菜单2("床位表维护", "床位表管理")
Call 子菜单2("价目表维护", "价目表维护")
Call 子菜单2("展开全部表", "展开全部表")
Call 主菜单("操作员")
Call 子菜单2("登录", "操作员登录")
Call 子菜单2("退出", "操作员退出")
' Dim ctl As CommandBarControl
' For Each ctl In Application.CommandBars(1).Controls 'Worksheet Menu Bar'Standard'Cell,"Worksheet Menu Bar"
' Debug.Print ctl.Index, ctl.Parameter, ctl.Caption ', ctl.OnAction'cb.Position, ,
' Next
End Sub
Private Sub 主菜单(myCaption As String)
Set MenuBar = Application.CommandBars(1).Controls.Add(Type:=msoControlPopup, temporary:=True) ' myMenuObject
With MenuBar
.Caption = myCaption
.Width = 50
.BeginGroup = True
.Tag = "自定义"
End With
End Sub
Public Sub 子菜单1(myCaption As String)
Set MenuItem = MenuBar.Controls.Add(Type:=msoControlPopup)
With MenuItem
.Caption = myCaption
.BeginGroup = True
End With
End Sub
Private Sub 子菜单11(myCaption As String, myOnAction As String)
Set SubMenuItem = MenuItem.Controls.Add(Type:=msoControlButton)
With SubMenuItem
.Caption = myCaption
.OnAction = myOnAction
.BeginGroup = True
End With
End Sub
Private Sub 子菜单2(myCaption As String, myOnAction As String)
Set MenuItem = MenuBar.Controls.Add(Type:=msoControlButton)
With MenuItem
.Caption = myCaption
.OnAction = myOnAction
.BeginGroup = True
End With
End Sub
|
|