Microsoft KB Archive/243988

= WD2000: How to Generate a List of Command Bar Names, Captions, and ID Numbers =

Article ID: 243988

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q243988





SUMMARY
In Microsoft Word, each element of the CommandBars collection uses a unique number for its ID property. This number determines the built-in action for each control in the CommandBars collection.

NOTE: The value of the ID property for Custom controls is 1.

The CommandBars collection consists of CommandBar objects. The following items are represented by CommandBar objects:
 * Menu bars, toolbars, and shortcut menus
 * Menus on menu bars and on toolbars
 * Submenus on menus, on submenus, and on shortcut menus



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

The following macro example lists, in a new Word document, each of the controls in the CommandBars collection and its corresponding ID number. The controls and their ID numbers are arranged according to the CommandBar to which the control belongs, as in the following:

CommandBar Name: Standard | Caption: New &Blank Document | Face Id : 3813

CommandBar Name: Standard | Caption: &Open... | Face Id : 23

CommandBar Name: Standard | Caption: &Save | Face Id : 3

CommandBar Name: Standard | Caption: &Mail Recipient | Face Id : 3738

CommandBar Name: Standard | Caption: &Print | Face Id : 2521

Sub FindFaceIDsWordDocument

'This code prints the information to a new Word document.

Dim c As CommandBar, ctl As CommandBarControl

Application.Documents.Add

For Each c In Application.CommandBars For Each ctl In c.Controls If ctl.Type = msoControlButton Then Selection.TypeText "CommandBar Name: " & c.Name & _ " | Caption: " & ctl.Caption & " | Face Id : " & ctl.FaceId Selection.TypeParagraph End If  Next Next

End Sub

