Section 19.3. Running Macros


19.3. Running Macros

Word gives you three ways to run macros. You can use a keyboard shortcut, as shown in the previous example. Or you can create a button on the Quick Access toolbar (in the upper-left corner of the Word window) that runs your macro. The third option is to run your macro from the Macro box (Developer Code Macros). The first two options, keyboard shortcut and button, are the quickest and easiest . The advantage of the Macro box is that it lists all available macros and gives you lots of other options for working with your macros.

19.3.1. Adding a Macro to the Quick Access Toolbar

You can assign your macro to a button when you first create it by clicking on the "Assign macro to" button in the Record Macro box. If you do, you see a new button on the Quick Access toolbar. Then you can run the macro with a click of a button. However, it's still not too late to create a button that runs your SentenceStrikeThruBlue macro. Follow these steps:

  1. Choose Office button Word Options Customize to see the settings to customize the Quick Access toolbar (Figure 19-9) .

    The list box on the left shows available commands, and the list box on the right shows commands that are included in the Quick Access toolbar.

  2. In the "Choose commands from" drop-down menu, select Macros .

    The "Choose commands from" drop-down menu determines which commands appear in the list box on the left. Selecting Macros from the list limits your choices to macros.

  3. Double-click the macro named Project.NewMacros.SentenceStrikeThruBlue to add it to the list of Quick Access toolbar commands on the right .

    Word macros have somewhat long names separated by dots (.) It's all part of the Visual Basic lingo, and if you choose to spend time working with macros and Visual Basic, it'll become familiar. For now, find the macro with a name that ends in SentenceStrikeThruBlue. (You may need to drag the right-hand border of the Word Options box to see the full macro names .)

    Figure 19-9. Use the Customize settings in Word Options to assign buttons to the macros you record. In the "Choose commands from" drop-down menu, choose Macros to show the available macros. Double-click a macro name to add it to the list of Quick Access Toolbar commands on the right.


  4. At the bottom of the list box, click the Modify button to change your macro's Quick Access toolbar icon .

    Word gives all macros the same icon, which looks a little like a decision tree or an organizational chart. If you plan to have more than one macro on your Quick Access toolbar, give each one a different icon. When you click Modify, a box opens showing dozens of icons (Figure 19-10).

    Figure 19-10. The Modify Button box shows dozens of icons you can use for your macros. Choose a button that helps identify the actions performed by the macro.


  5. Click to select an icon (the blue bull's-eye is a good choice for this macro), and then click OK to close the Modify Button box. Click OK to close the Word Options box .

  6. After you close the Word Options box, you see your new macro button at the end of the Quick Access toolbar. When you move your mouse cursor over the blue bull's-eye, a screen tip with the macro's name pops up.

To test the command, just click to place your insertion point in a sentence , and then, on the Quick Access toolbar, click the bull's-eye button.

19.3.2. Running a Macro from the Macros Box

It's quickest to run a macro with a keyboard shortcut or from the Quick Access toolbar. However, at times you may want to run them from the Macros box. For example, since the Macro box lists all available macros in the current document or template (Figure 19-11), it's a convenient way to test or edit all your macros. To open the Macros box, go to Developer Code Macros or press Alt+L, PM.

Figure 19-11. The Macro box (Alt+L, PM) lists the available macros and gives you lots of ways to modify them. Macros are listed in the "Macro name" box. Choose a file or template in the "Macros in" drop-down menu to limit the number of macros showing. The buttons on the right let you run, modify, and create new macros.


To run a macro from the Macros box, just select it in the "Macro name" list, and then click the Run button at top right. The Macro box closes and the macro runs, just as if you'd clicked the button or used the keyboard shortcut.


Tip: You can undo a macro command by pressing Ctrl+X or clicking the Undo button on the Quick Access toolbar. Word steps through the commands, so if there were three commands (as in the SentenceStrikeThruBlue macro), you must press Ctrl+Z three times.


Word 2007[c] The Missing Manual
Word 2007[c] The Missing Manual
ISBN: 059652739X
EAN: N/A
Year: 2006
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net