ACCESS 如何获取所有菜单栏命令按钮的图片以及FaceID?

博客聚焦于信息技术领域,探讨如何获取所有菜单栏命令按钮的图片以及FaceID,涉及编程相关内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如何获取所有菜单栏命令按钮的图片以及FaceID?

 

问题:

如何获取所有菜单栏命令按钮的图片以及FaceID?
我自己编写程序时要定义菜单,但是我不知道系统中定义图片的 FaceID 是多少。

 

回答:

你直接将以下程序 COPY 到你新建的模块中去,然后将光标定位在“Public Function GetAllFaceID_1()”处,按 F5 运行即可。程序会自动生成几个工具栏,里面列出所有的 Face 以及 FaceID。
Function CommandBarIsExist(ByVal strName As String) As Boolean
'引用 OFFICE OBJECT Library
    Dim b As CommandBar
    CommandBarIsExist = False
    For Each b In CommandBars
        If b.Name = strName Then
            CommandBarIsExist = True
            Exit For
        End If
    Next
End Function

Public Function GetAllFaceID_1()
'将所有的 FACE 图片显示在几个工具栏中
'只要在自定义时显示工具栏即可

    Dim b As CommandBar
    Dim c As CommandBarControl
    Dim p As CommandBarPopup
    Dim p1 As CommandBarPopup
    Dim strName As String
    Dim cmbC As CommandBarComboBox
    Dim cmbB As CommandBarButton
    Dim i As Long
    
On Error Resume Next
    
    
    
    '重新定义菜单项目
    'Type 属性应用于 CommandBarButton、CommandBarComboBox、CommandBarControl 和 CommandBarPopup 对象的情形。
    '返回命令栏控件的类型。MsoControlType 类型,只读。
    'MsoControlType 可以为下列 MsoControlType 常量之一。
    'msoControlActiveX
    'msoControlAutoCompleteCombo
    'msoControlButton
    'msoControlButtonDropdown
    'msoControlButtonPopup
    'msoControlComboBox
    'msoControlCustom
    'msoControlDropdown                 '与 combo 的区别是只能单击下拉,不能修改
    'msoControlEdit
    'msoControlExpandingGrid
    'msoControlGauge
    'msoControlGenericDropdown
    'msoControlGraphicCombo
    'msoControlGraphicDropdown
    'msoControlGraphicPopup
    'msoControlGrid
    'msoControlLabel
    'msoControlLabelEx
    'msoControlOCXDropdown
    'msoControlPane
    'msoControlPopup
    'msoControlSpinner
    'msoControlSplitButtonMRUPopup
    'msoControlSplitButtonPopup
    'msoControlSplitDropdown
    'msoControlSplitExpandingGrid
    'msoControlWorkPane
    'On Error Resume Next
    
    
    For i = 0 To 10000
        If i Mod 1000 = 0 Then
            strName = "cg tools" & i
            If CommandBarIsExist(strName) = True Then
                Set b = CommandBars.Item(strName)
                b.Delete
            End If
            Set b = CommandBars.Add(Name:=strName, Position:=msoBarFloating, MenuBar:=False, Temporary:=True)
        End If
    
        Debug.Print i
        Set cmbB = b.Controls.Add(msoControlButton, , , , True)
        cmbB.Caption = i
        cmbB.FaceId = i
        DoEvents
    Next
End Function


Public Function GetAllFaceID_2()

    Dim b As CommandBar
    Dim c As CommandBarControl
    Dim p As CommandBarPopup
    Dim p1 As CommandBarPopup
    Dim strName As String
    Dim cmbC As CommandBarComboBox
    Dim cmbB As CommandBarButton
    Dim i As Long
On Error Resume Next
    
    strName = "cg tools"
    If CommandBarIsExist(strName) = True Then
        Set b = CommandBars.Item(strName)
        b.Delete
    End If
    
    
    Set b = CommandBars.Add(Name:=strName, Position:=msoBarFloating, MenuBar:=False, Temporary:=True)
    
    
    
    '重新定义菜单项目
    'Type 属性应用于 CommandBarButton、CommandBarComboBox、CommandBarControl 和 CommandBarPopup 对象的情形。
    '返回命令栏控件的类型。MsoControlType 类型,只读。
    'MsoControlType 可以为下列 MsoControlType 常量之一。
    'msoControlActiveX
    'msoControlAutoCompleteCombo
    'msoControlButton
    'msoControlButtonDropdown
    'msoControlButtonPopup
    'msoControlComboBox
    'msoControlCustom
    'msoControlDropdown                 '与 combo 的区别是只能单击下拉,不能修改
    'msoControlEdit
    'msoControlExpandingGrid
    'msoControlGauge
    'msoControlGenericDropdown
    'msoControlGraphicCombo
    'msoControlGraphicDropdown
    'msoControlGraphicPopup
    'msoControlGrid
    'msoControlLabel
    'msoControlLabelEx
    'msoControlOCXDropdown
    'msoControlPane
    'msoControlPopup
    'msoControlSpinner
    'msoControlSplitButtonMRUPopup
    'msoControlSplitButtonPopup
    'msoControlSplitDropdown
    'msoControlSplitExpandingGrid
    'msoControlWorkPane
    'On Error Resume Next

    
    
    For i = 0 To 10000
        Debug.Print i
        If i Mod 500 = 0 Then
            Set p = b.Controls.Add(msoControlPopup, , , , True)
            p.Caption = i
        End If
        
        If i Mod 25 = 0 Then
            Set p1 = p.Controls.Add(msoControlPopup, , , , True)
            p1.Caption = i
        End If
        Set cmbB = p1.Controls.Add(msoControlButton, , , , True)
        cmbB.Caption = i
        cmbB.FaceId = i
        DoEvents
        
    Next
End Function


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值