找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 数据库 查看内容

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

2009-12-14 18:36| 发布者: admin| 查看: 32| 评论: 0|原作者: 韩菱纱

□问题: 如何获取所有菜单栏命令按钮的......


问题:


如何获取所有菜单栏命令按钮的图片以及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


最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 21:32 , Processed in 0.223548 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部