Finding Face ID Numbers for Your Microsoft Office 97 Toolbars

Charlie Kindschi
Microsoft Corporation

July 10, 1998

Click here to copy the FaceID sample discussed in this article.

The ability to create custom toolbars is one of the great features of Microsoft® Office 97. Custom toolbars, also called command bars, are integral to most Office-based solutions. Choosing appropriate images, or icons, for your button faces helps make the function of each toolbar button self-explanatory. This article explains how to find the face ID numbers (values for the FaceID property) that correspond to the button images you use on Office toolbars you've created programmatically.

The article also includes a tool that makes finding the perfect button image for any given custom toolbar button very easy (click on the hot text above to download). If you're familiar with face ID numbers and how to use them, feel free to download the tool and skip to the section of this article titled "Using the Face ID Finder" for instructions on this free tool.

Why Not Just Create Custom Toolbars with the User Interface?

You can create custom toolbars for your Office applications in one of two ways: by working with the user interface, or by using Visual Basic® for Applications (VBA) procedures. Toolbars created with the user interface are very useful for prototyping. In the prototype phase of a project, you can use interface-generated toolbars to get a feel for how you want the finished product to look and feel. Most developers, however, choose to employ VBA code to generate toolbars for projects that others will use.

One advantage of creating toolbars programmatically is that this makes your applications more "bulletproof." For example, suppose that your custom application won't work correctly without a specific custom toolbar. If you create the toolbar through the user interface and a user later deletes it (by using that same interface), the result is a broken application. On the other hand, if a user does the same thing to a custom toolbar that you created programmatically, the toolbar will be recreated the next time the procedure that created it is run. It's standard practice to call such procedures whenever a custom application is opened; this way, if a vital toolbar is subsequently deleted, the application seems to "heal" itself the next time it's opened.

Another reason to create custom toolbars with Visual Basic for Applications code is increased flexibility. You can change virtually any property of one of these toolbars at run time. For example, you can program captions and button images to automatically change in response to specific events within the application.

Face ID Numbers and Toolbars

To understand the relationship between face ID numbers and custom toolbars, take a look at the following Visual Basic for Applications procedure.

Public Function CreateFromBar ()
     Dim cmdBar As CommandBar
     Dim btnForm As CommandBarButton
' Delete the object if it already exists.
     On Error Resume Next
     Application.CommandBars ("ShowForm").Delete
'Set the CommandBar object variable.
     Set cmdBar = Application.CommandBars.Add
          CmdBar.Name = "ShowForm"
'Add a button.
     With cdmBar.Controls

          Set btnForm = .Add(msoControlButton)

     End With
'Set the new button's properties.
     With btnForm
          .Style = msoButtonIconAndCaption
          .Caption = "Show FaceID Finder Form"
          .FaceID = 204
          .OnAction = "OpenForm"
          .TooltipText = "Show FaceID Form"
     End With
CmdBar.Visible = True
End Function

The CreateFormBar procedure shown here is used in the Face Id Finder tool. The procedure creates a single-button toolbar, as shown in the following illustration.

Figure 1. The ShowForm custom toolbar

Part of the price of creating custom toolbars by using Visual Basic for Applications procedures is that you need to provide face ID property values that correspond to the button images you want to display. The button image shown in the preceding illustration corresponds to face ID number 2104. There are literally thousands of button images available for you to use in Office-based projects. The challenge lies in choosing face IDs that are appropriate to your project. This is where the Face ID Finder tool comes in so handy.

Using the Face ID Finder

Download and open FaceID.xls. The worksheet opens with the user form shown in the following illustration.

Figure 2. FaceID Number Finder form

By entering numbers in the First FaceID Number and Last FaceID Number boxes, then clicking Show Button Faces, you can view up to 200 button face images and their associated face ID numbers at the same time. You can then repeat this process, increasing the starting and ending numbers each time until you find a face ID that suits your purpose.

Just to experiment, type 200 and 300 in the First Face ID Number and Last FaceID Number boxes, respectively, and then click Show Button Faces. The status bar and mouse pointer will change, indicating that the program is working. When it's finished running, a large toolbar like the one shown in the following illustration is displayed. The ToolTip text for each button image contains that button's face ID number. For example, the face ID number for the eyeglasses button face selected in this illustration is 229.

Figure 3. 100 Face IDs and button images

See How a Particular Button Image Looks on Your Custom Toolbar

After you've located the face ID number that suits your needs, simply substitute its number as the value of the FaceID property for the btnForm toolbar button created in the CreateFormBar procedure, then run the procedure again. To do this, you can paste the CreateFormBar procedure (shown earlier in this article) into a new code module, or you can open Module1 in the FaceID.xls project and locate the procedure there.

Note   The user form frmFaceID is protected from invalid input by a validation procedure. For example, the text boxes on the form will not accept nonnumeric (text) entries and, if the number in the First FaceID Number box entered is greater than the number in the Last FaceID Number box, the numbers are automatically transposed. If you're interested in this sort of validation code, see the Validate in Module1 procedure (complete with comments) in the FaceID.xls project.

Summary

As you can see, custom toolbars can contain nearly any number of toolbar buttons, and after you've found the face ID number associated with a given button image, attaching that image to a button is a snap.