microsoft.com Home  
Microsoft
http://www.microsoft.com/office/ork  
Microsoft Office 2000 Resource Kit Home
 Managing and Supporting Office 2000
 Ongoing Configuration of Office on Users' Computers
Managing Users' Options with System Policies
Locking Down an Office Configuration
Using the System Policy Editor
Office 2000 System Policy Reference
Office Registry API
 Helping Users Help Themselves
 Managing Security
 Overview of Tools and Utilities
Glossary
Index
Topic Contents
Next
Previous
Using the System Policy Editor

Control IDs for Menu Commands and Toolbar Buttons

You can look up control IDs for any item on a menu or toolbar in Microsoft Office 2000 applications by using Visual Basic for Applications (VBA). You enter the control ID into the System Policy Editor to disable that menu command and toolbar button. You can either look up a single control ID or use a macro to find a series of control IDs.

Note   Menu commands and their corresponding toolbar buttons share the same control ID. For example, the control ID for both the Save command (File menu) and the Save button (Standard toolbar) in Microsoft Word is 3.

Finding a single control ID

You can use the Immediate window in VBA to look up the control ID for a single item on a menu. For example, the following command displays the control ID for the Save As command (File menu):

? commandbars ("menu bar").controls ("file").controls ("save as…").id

Note   For Microsoft Excel, use “worksheet menu bar” instead of “menu bar” in the previous command.

You use the same command to find the control ID for a toolbar button. For example, the following command displays the control ID for the Document Map button (Standard toolbar) in Word:

? commandbars ("standard").controls ("document map"). id

Top

Finding all the control IDs for a menu or toolbar

If you want to find the control IDs for all the items on a menu or toolbar, you can create a macro in VBA. For example, the following macro opens a series of message boxes to display the commands and corresponding control IDs for each item on the File menu for any Office 2000 application:

Sub EnumerateControls()
    Dim icbc As Integer
    Dim cbcs As CommandBarControls

    Set cbcs = Application.CommandBars("Menu Bar").Controls("File").Controls
    For icbc = 1 To cbcs.Count
        MsgBox cbcs(icbc).Caption & " = " & cbcs(icbc).ID
    Next icbc
End Sub

Note   To disable all of the items on a menu, you can enter each item individually in the System Policy Editor. Or, you can disable the entire menu by entering the control ID for the menu itself.

Top

See also

For more information about using Visual Basic for Applications, see the Microsoft Office 2000/Visual Basic Programmer’s Guide.



Topic Contents   |   Previous   |   Next   |   Top

  Friday, March 5, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of use.

License