top of page
  • John

VBA and FaceIds

Updated: Sep 15, 2023

A FaceId, in VBA, is a small picture/icon added to a CommandBarButton which is an item in a menu. The main menus in all Office applications were phased out with Office 2007 and replaced by the 'ribbon' so FaceIds are less relevant now. However, they:

  • Can still be used in custom context menus

  • Are still used in the menus of the Visual Basic Editor (VBE) … this is only useful if you are customising the VBE itself, though!

  • Can be used in other places e.g. in Image or Label Controls on UserForms (see code below)

Each FaceId has a unique number and understanding which FaceId picture is associated with what number can be difficult as there is no way to do a text search for a FaceId, you just have to trawl through each one. A great resource is https://bettersolutions.com/vba/ribbon/face-ids-2003.htm, however, this skips some FaceId numbers (many of which genuinely only return a blank FaceId ... but not all) and only goes up to FaceId 9996.


My FaceIds Tool (available below) will allow you to see many of the blanks and all of the FaceIds up to number 34548. There are various other equivalents of this tool available on the internet: I think my version improves on those by displaying more FaceIds, and doing so much faster.


Below is an example created from my tool, this is a screenshot of the FaceIds from 25001 to 26000 including the various angry / quizzical, sad, surprised etc faces.

FaceIds

Pretty little pictures are all well and good, but how do you use them?


Here is an example of getting a picture (actually an IPictureDisp) from a FaceId number and put it onto a Label Control in a UserForm ... this Function does the heavy lifting:

This Function will work as-is in Excel, Word and PowerPoint. If you're working in Outlook then it needs a tweak: following each of the three references of Application and before each of the three references of CommandBars, add a reference of ActiveWindow, eg

This is because, in the Outlook object model, the CommandBars collection is not a direct child of the Application object, rather it is a child of the active Inspector or active Explorer objects (the active one of which is returned by ActiveWindow) ... check out the Outlook object model for more info!


Whichever app you are using, you can then use the GetPictureFromFaceId() Function in your UserForm code. For example, in UserForm_Initialize():

On a side note, the reason I use a Label Control as opposed to what might seem like the more obvious Image Control is that I find a Label to have a cleaner appearance without unnecessary background and border effects. However, GetPictureFromFaceId() can be used with an Image Control just the same.


And on another side note, why would you bother using a FaceId at all compared to, for example, a custom icon or picture? The answer is simply that they are built into the application: you don't have to bundle a separate graphics file with your Workbook / Document / Presentation or embed that file into (eg) a Worksheet and extract it out at runtime. True, it's not always simple to find the right FaceId for the occasion, but once you have then the code to use it is simple and re-usable.


Get the FaceIds Tool


Download the FaceIDs.zip file, unblock it (if you're not sure how to do that, see my blog post Unblock a file containing VBA code), unzip the Workbook then open it.

Once opened, click the 'Click me' button, select an initial range of 1000 FaceIds to show, then use the Previous and Next buttons to move to other ranges of FaceIds. Hover over a FaceId to see its number or click on a FaceId to copy its number to the clipboard.


Other links to MS Docs relating to this post

0 comments

Comments


bottom of page