Chapter 8: VBE- Programming Toolbars

            The most basic manner of working with code in MS Word is to record a macro, then make  the macro available for use either via keyboard shortcuts, through the use of UserForms objects (s.a. clickbuttons), or in toolbar controls. Toolbars are useful objects that are active and available at all times, which can be used to call up forms, print out reports, and perform other useful events. In the exercise below, you will add a menu item and assign to it VBA code.

Here are is the way to make a toolbar object and assign to it a macro. Once completed,  you will only have to press a button to test the recorded task.

Step 1: Record the Macro

If you would like the macro to be available only in a specific file, open that file first. From the menu, choose Tools ŕ Macro ŕ Record New Macro. The following dialog box will appear:


        The following textboxes need to be filled:

  • In the Macro name box, enter the name you would like to use for your macro. It must not have any spaces and should not contain special characters.

  • In the Store macro in section, decide where to store the macro. If you would like it available in the current document only, hit the Store Macro in drop-down box and select your active document's name. If you would like the macro to be available for use with any file, select All Documents (

  • In the Description section, you can give the macro any description you like. By default, the description will state the date the macro was recorded, and the user name. The user name automatically comes from the information under Word's Tools-Options, User Info tab.

            Click on either Toolbars or on the Keyboard to assign the macro.  For this exercise, click on the Keyboard button. The Customize Keyboard dialog will appear:

As before, in the right column under Commands, you will see an icon with a title similar to your macro's name. For the Press new shortcut key textbox, click on a keyboard combination to assign a keyboard “hot” combination; in this case, “Alt+X” was selected. Make sure that in the Save changes in combobox there is the deployment selection you want; in this case, “” has been selected. Once you have all of your selections just as you want them, click on Assign, then click on Close.

Perform the tasks that are needed for this macro, then press on the square clickbutton in the Stop Recording toolbar to stop the recording of actions. The circle is used to PAUSE recording.

Now you are ready to attach the macro to either a toolbar button or to a keyboard sequence.

Step 2: Assign the Macro to a Toolbar Button

            Right click on the Toolbars sectionŕ select Customizeŕ select Commands to go to the section where you can select your macro.

            Right click on the macro and drag it to your toolbars section. Your mouse pointer must have a plus sign (+) hanging on it before you lift your finger from the mouse or the icon will not be placed. Now right click on this toolbar object and the following will appear:


            You can now use these tools to add/edit a graphic and to name the toolbar object.

Step 3: Test the Macro

Always test a macro, particularly if you have created it to run for someone else. To test the macro, click on the toolbar button you've created, or hit Tools-Macro-Macros, and double-click the macro name.  For Keyboard macros, simply activate the assigned hot keys.

Applying this Tutorial to Your EMR Project

          At this point, you should:

  • Set up record a few macros, then add them to your Toolbar area. You may wish to add a few clickbuttons that call up important primary UserForms.