|
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 MacroIf 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:
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, “Normal.dot” 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 ButtonRight 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 MacroAlways 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 ProjectAt this point, you should:
|