|
本帖最后由 micch 于 2023-5-3 14:39 编辑
菜单有了,具体的功能代码自己再写一下就行了
- Const CommandbarName As String = "MenuBar0" '---菜单名称
- Sub SetCustomMenu()
- Set HostApp = Application
- Dim myBar As CommandBar
- Dim myButton As CommandBarButton
- Dim capAr, fac, ccc
- On Error Resume Next
- HostApp.CommandBars(CommandbarName).Delete
- On Error GoTo 0
- Set myBar = HostApp.CommandBars.Add(Name:=CommandbarName, _
- Position:=msoBarTop, _
- MenuBar:=True, _
- Temporary:=True)
- capAr = [a1:c4] ''''' 先把菜单名称写在单元格中
- fac = 157
- For Each ccc In Application.Transpose(capAr)
- Set myButton = myBar.Controls.Add(msoControlButton)
- myButton.Style = msoButtonIconAndCaption
- myButton.Caption = ccc
- myButton.OnAction = Left(ccc, 4) & "_" & Mid(ccc, 6)
- myButton.FaceId = fac
- Next
- myBar.Protection = msoBarNoMove + msoBarNoCustomize
- myBar.Visible = True
- With HostApp.CommandBars
- .LargeButtons = True
- .DisplayFonts = True
- .AdaptiveMenus = True
- End With
- End Sub
- Sub 基础信息_学校信息()
- VBA.MsgBox "基础信息_学校信息"
- End Sub
- Sub 基础信息_班级信息()
- VBA.MsgBox "基础信息_班级信息"
- End Sub
- Sub 基础信息_库房信息()
- VBA.MsgBox "基础信息_库房信息"
- End Sub
- Sub 设备信息_配备标准()
- VBA.MsgBox "设备信息_配备标准"
- End Sub
- Sub 设备信息_历年数据()
- VBA.MsgBox "设备信息_历年数据"
- End Sub
- Sub 设备信息_今年数据()
- VBA.MsgBox "设备信息_今年数据"
- End Sub
- Sub 账目信息_总账()
- VBA.MsgBox "账目信息_总账"
- End Sub
- Sub 账目信息_明细账()
- VBA.MsgBox "账目信息_明细账"
- End Sub
- Sub 账目信息_综合报表()
- VBA.MsgBox "账目信息_综合报表"
- End Sub
- Sub 使用信息_领借用记录()
- VBA.MsgBox "使用信息_领借用记录"
- End Sub
- Sub 使用信息_归还记录()
- VBA.MsgBox "使用信息_归还记录"
- End Sub
- Sub 使用信息_报损记录()
- VBA.MsgBox "使用信息_报损记录"
- End Sub
- Public Sub DeletemyMenu()
- On Error Resume Next
- CommandBars(CommandbarName).Delete
- End Sub
复制代码
|
|