Displaying CommandBar FaceID Images

If you create custom menus or toolbars, you're probably familiar with the FaceId property -- a numeric value that specifies an image. People have come up with lots of ways to display the FaceId images. Here's one I haven't seen before.

Start with an empty workbook, and paste the ShowFaceIDs procedure into a VBA module. Adjust the ID_START and ID_END constants to specify which images you'd like to see (it's currently set up to show the first 500). Run the macro, and the 18 x 18 pixel images are displayed on the active worksheet. Click an image and you'll see it's FaceID value in the Name box.

Sub ShowFaceIDs()
    Dim NewToolbar As CommandBar
    Dim TopPos As Long, LeftPos As Long
    Dim i As Long, NumPics As Long

'- - - - - Change These - - - - -
    Const ID_START As Long = 1
    Const ID_END As Long = 500
'- - - - - - - - - - - - - - - - - - - -

'   Delete existing TempFaceIds toolbar if it exists
    On Error Resume Next
    Application.CommandBars("TempFaceIds").Delete
    On Error GoTo 0

'   Clear the sheet
    ActiveSheet.Pictures.Delete
    Application.ScreenUpdating = False
   
'   Add an empty toolbar
    Set NewToolbar = Application.CommandBars.Add _
        (Name:="TempFaceIds")

'   Starting positions
    TopPos = 5
    LeftPos = 5
    NumPics = 0
   
    For i = ID_START To ID_END
        On Error Resume Next
        NewToolbar.Controls(1).Delete
        With NewToolbar.Controls.Add(Type:=msoControlButton)
            .FaceId = i
            .CopyFace
        End With
        On Error GoTo 0
       
        NumPics = NumPics + 1
        ActiveSheet.Paste
        With ActiveSheet.Shapes(NumPics)
            .Top = TopPos
            .Left = LeftPos
            .Name = "FaceID " & i
            .PictureFormat.TransparentBackground = True
            .PictureFormat.TransparencyColor = RGB(224, 223, 227)
        End With
       
'       Update top and left positions for the next one
        LeftPos = LeftPos + 16
        If NumPics Mod 40 = 0 Then
            TopPos = TopPos + 16
            LeftPos = 5
        End If
    Next i
    ActiveWindow.RangeSelection.Select
    Application.CommandBars("TempFaceIds").Delete
End Sub

Even if you don't create CommandBars, you might have fun looking at all the little pictures.

11 Comments

  1. Richard Schollar:

    Hi John

    This is a great fun piece of code - my personal favourite has to be number 4000 (it's a little doggie ;-) ). Thanks for sharing!

    Richard

  2. Jerry:

    How about this
    Create 6 Commandbars, each contains 600 icons(FaceID)
    Cascading displayed, shows FaceID No when cursor
    move on it

    Sub AddButton()
    Dim GName As String
    Dim I As Integer, J As Single
    For I = 6 To 1 Step -1 ' Display from bottom to top
    GName = "Group" & 600 * (I - 1) + 1 & "_" & 600 * I
    On Error GoTo Endline
    With Application.CommandBars.Add(GName)
    .Visible = True
    With .Controls
    For J = 600 * (I - 1) + 1 To 600 * I
    On Error Resume Next
    With .Add(msoControlButton)
    .FaceId = J
    .Caption = J
    End With
    Next
    End With
    End With
    Endline:
    With CommandBars(GName)
    .Visible = True
    .Width = 720 ' contains 30x20 icons
    .Left = 50 + (6 - I) * 20
    .Top = 90 + (6 - I) * 20
    End With
    Next I
    End Sub

  3. Henk:

    There's a lot to choose but is there a way that i can make my own images by VBA?
    I don't want to send an image with my macro's but my macro must build an image!
    (example: 1st pixel: grey, 2nd pixel: red etc.)
    Do you think that can make an image with VBA??

  4. Henk:

    There's a lot to choose but is there a way that i can make my own images by VBA?
    I don't want to send an image with my macro's but my macro must build an image!
    (example: 1st pixel: grey, 2nd pixel: red etc.)
    Do you think that you can make an image with VBA??

  5. Andy Pope:

    Hi Henk,

    You could pick apart my code from this addin.
    http://www.andypope.info/vba/buttoneditor.htm

  6. MikeC:

    I don't create CommandBars often.

    But it WAS fun looking at all the little pictures!

  7. John Walkenbach:

    Jerry, your technique is the one that's most-often used. But try it in Excel 2007. Not a pretty sight. You get three rows of icons, and you have to scroll horizontally 25 times to see them all. That was my motivation to show them on a worksheet.

    Although FaceID images don't have much use in Excel 2007, I still like to use them sometimes for images on UserForm controls.

  8. Jon Peltier:

    I have a little FaceID browsing utility that I use frequently when I want to dig up some icons for a project:

    http://peltiertech.com/Excel/Zips/ShowFace.zip

    As John points out, it will suck in 2007.

  9. John Walkenbach:

    Plus, some of them have changed. If you install Office 2007, your old CommandBar images may not be the same -- even when you use Office 2003.

  10. Jon Peltier:

    Yes, they redesign the icons from time to time. The icons for the Office programs change slightly each version, and the whole collection of icons got facelifts (face-ID-lifts?) for Office 2003. I hadn't noticed that the 2003 icons were affected by the Office 2007 installation on the same machine.

  11. Rob van Gelder:

    I too have written the add-in, but I use the command bars within VBA to display them.
    I chose VBA since that's where I'm most likely to need the IDs.

    FaceID Explorer
    Available on my website www.vangelder.co.nz

    I dont know how it looks in 2007... probably rubbish.

    Rob

Leave a comment