你直接将以下程序 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
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)
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