Excel Developer Tip


Return to The Spreadsheet Page

Excel page

Tip archives

Identifying CommandBar Images

If you use Excel 97 or later, you know that it uses many images in its built in menus and toolbars. You can use these built-in images in your custom menus and toolbars by setting the FaceId property to a particular integer. The problem, however, is determining which integer corresponds to each image.

The subroutine below creates a custom toolbar with the first 250 FaceID images (shown below). You can see even more images by changing the values for IDStart and IDStop. The last FaceID image appears to be number 3518 (there are also many blank images).

Toolbar created by the ShowFaceIDs subroutine

After creating the toolbar, move the mouse pointer over a button to find out the FaceID value for the image. Clicking the toolbar buttons will have no effect since the subroutine doesn't assign any macros to the OnAction properties.

The ShowFaceIds Subroutine

Sub ShowFaceIDs()
    Dim NewToolbar As CommandBar
    Dim NewButton As CommandBarButton
    Dim i As Integer, IDStart As Integer, IDStop As Integer
    
'   Delete existing FaceIds toolbar if it exists
    On Error Resume Next
    Application.CommandBars("FaceIds").Delete
    On Error GoTo 0
    
'   Add an empty toolbar
    Set NewToolbar = Application.CommandBars.Add _
        (Name:="FaceIds", temporary:=True)
    NewToolbar.Visible = True
    
'   Change the following values to see different FaceIDs
    IDStart = 1
    IDStop = 250
    
    For i = IDStart To IDStop
        Set NewButton = NewToolbar.Controls.Add _
            (Type:=msoControlButton, Id:=2950)
        NewButton.FaceId = i
        NewButton.Caption = "FaceID = " & i
    Next i
    NewToolbar.Width = 600
End Sub 

Another Approach

Some may prefer to use the handy macro created by John McLean. This macro, when executed, displays every FaceID image in a worksheet grid for easy reference. John has made this file available, and you can download it here.

Or, you may prefer to download an add-in