Datasheet

532
If you use the Find or Replace commands, be sure to move to the begin-
ning of the document first.
Avoid any commands that depend on the contents of a document that’s
active when you record the macro. If your macro is based on informa-
tion that will never be replicated, it’s a useless macro.
Running a Macro
If you assigned a macro to the Quick Access toolbar or a keyboard shortcut,
you can run the macro by clicking the Quick Access Toolbar button or press-
ing the keyboard shortcut. If you didn’t, you can run it by following these
steps:
1. Select the Developer tab on the Ribbon and then click the Macros
button in the Code group.
The Macros dialog box, shown in Figure 1-3, appears.
For a shortcut, you can press Alt+F8.
2. If the macro you want to run isn’t already selected, select it now. If the
macro you want doesn’t appear, try changing the Macros In setting.
The macro might be in a different template.
3. Click Run.
Sometimes a macro has unexpected side
effects. Suppose that rather than record the
keystrokes Ctrl+B and Ctrl+I for the BoldItalic
macro, you decide to record these steps:
1. Click the Font group button to display the
Font dialog box.
2. Choose Bold Italic as the font style.
3. Click OK.
The macro seems to work, but sooner or later
you discover that in addition to recording the
Bold Italic font style, the macro recorded other
character attributes — such as the font, size,
and effects. If the text to which you applied the
Font dialog box command when you recorded
the macro was 10-point Times New Roman
font, every time you apply the macro, the font
switches to 10-point Times New Roman.
You can avoid these side effects in two ways:
Avoid recording dialog boxes in macros
whenever a keyboard shortcut or a Ribbon
button can do the trick. Whenever you
record a dialog box in a macro, you record
all the dialog box settings.
Fix the macro later by editing it and remov-
ing the extraneous information. See the
later section “Editing a Macro.”
Avoiding unexpected side effects
Running a Macro
50_487662-bk09ch01.indd 53250_487662-bk09ch01.indd 532 4/15/10 9:18 PM4/15/10 9:18 PM