Finding built-in toolbar icons


Q: How can I select icons for my custom toolbar from the built-in icons in MS Office 

A. Create a user form with a label (lblShowNumbers) and four command buttons (cmdClose, cmdShow, mdNext200, and cmdPrevious 200)

Type the following code in the user form


Option Explicit

Dim cbrFaces As CommandBar
Dim intFirstImage As Integer                      'Number of first image to show

Private Sub ShowImages()
'This procedure retrieves the icons

  Dim intCount As Integer
  Dim ctlAny As CommandBarControl

  frmFaces.MousePointer = fmMousePointerHourGlass  'Show hourglass

  With cbrFaces                                    'Retrieve all icons
    For intCount = 1 To 200
      .Controls(intCount).FaceId = intCount + intFirstImage - 1
      .Controls(intCount).TooltipText = "FaceID = " & CStr(intCount + intFirstImage - 1)
    Next intCount
  End With
  'Add text
 
lblShowNumbers.Caption = "Showing Faces " & intFirstImage & " - " & (intFirstImage + 199)

  frmFaces.MousePointer = fmMousePointerDefault    'Show normal mouse icon

End Sub


Private Sub cmdClose_Click()
'This procedure closes the user form
  Set cbrFaces = Nothing
  Unload Me
End Sub
Private Sub cmdNext200_Click()
'This procedure retrieves the next 200 icons

  intFirstImage = intFirstImage + 200                 'Change value of intFirstImage
  ShowImages                                          'Retrieve icons

End Sub
Private Sub cmdPrevious200_Click()
'This procedure retrieves the previous 200 icons
 
intFirstImage = intFirstImage - 200
  If intFirstImage < 1 Then intFirstImage = 1
  ShowImages
End Sub
Private Sub cmdShow_Click()
'This procedure allows you to start anywhere
  intFirstImage = Val(InputBox("Type first FaceID to show", "Select Faces"))
  If intFirstImage < 1 Then intFirstImage = 1
  ShowImages
End Sub
Private Sub UserForm_Initialize()
  Dim ctlAny As CommandBarControl
  Dim intCount As Integer
  Dim objApp As Object

  On Error Resume Next 'Avoid error trying to delete non-existing commandbar

  'Delete commandbar if it is still there
 
Application.CommandBars("Rest cursor on image to see FaceID").Delete

  Set objApp = Application

  'Position the form suitably
 
With objApp
    Me.Left = .Left + .Width / 50
    Me.Top = .Top + .Height / 5
  End With

  On Error GoTo 0

  'Create new commandbar
 
Set cbrFaces = Application.CommandBars.Add _
    ("Rest cursor on image to see FaceID", msoBarFloating)

  'Add all 200 controls
 
With cbrFaces.Controls
    For intCount = 1 To 200
      .Add msoControlButton
    Next intCount
  End With

  Me.Show                            'Show user form

  'Position and size commandbar
  cbrFaces.Width = 350
  cbrFaces.Top = 1.33 * Me.Top
  cbrFaces.Left = 1.4 * (Me.Left + Me.Width)
  cbrFaces.Visible = True
  intFirstImage = 1

  ShowImages                         'Load the icons
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Delete the commandbar when user form is closed

  Application.CommandBars("Rest cursor on image to see FaceID").Delete
End Sub

Opening the user form will display 200 available icons, and you can look at more icons using the buttons.as shown below

You can either open the Tools|Customize dialog window and copy a suitable icon from the list to your own button, or you can use the FaceID number in code.