MS Word

Record a Macro to Repeat a Task

I spend half the day creating the same type of document over and over again. I've streamlined things as much as possible with templates, AutoText, and AutoCorrect, but it's still duller than watching asphalt dry.

The Solution:

This sounds like a job for a macro or two. In short, you switch on the Macro Recorder, perform the series of actions that you want to be able to repeat at the touch of a button, and then stop the Macro Recorder. You can then play back the macro as often as needed. Here's how it works:

  1. Start Word and set up the document you want to automate.

  2. Choose Tools » Macro » Record New Macro to display the Record Macro dialog box (see Figure 8-1). Type a name for the macro (no spaces, but underscores are okay) in the "Macro name" box and provide a description in the "Description" box. In the "Store macro in" drop-down list, make sure that "All Documents (" is selected, unless you specifically want to store the macro in a different document or template. (If you do, the macro will be available only when that document, that template, or a document based on that template is open.)

    Figure 8-1. Assign a descriptive name and a detailed description to each macro you recordotherwise, your list of macros can quickly become confusing.

    The Record Macro dialog box also lets you choose a way of running the macro in the future: click the Toolbars button and use the Customize dialog box to assign the macro to either a toolbar button or a menu command, or click the Keyboard button and use the Customize Keyboard dialog box to assign a keyboard shortcut. Although this functionality is convenient, it's best not to use it, because you'll often need to move your recorded macros from the default location into which Word records them to a more permanent location. Moving them breaks any way you've assigned of running the macro, so it's best to move the macro before you assign it to a toolbar, menu, or keyboard shortcut.

  3. Click the OK button to start recording the macro. Word displays the Stop Recording toolbar, which contains a Stop Recording button and a Pause Recording/Resume Recording button. The mouse pointer displays an audio-cassette icon to indicate that recording is on.

  4. Perform the actions that you want the macro to repeat. You can perform almost all keyboard actionsfor example, moving the insertion point and selecting objectsand you can execute most commands from the menus. You cannot use the mouse to select objects or to drag the selection, although you can use the context menu to execute commands (for example, Cut or Paste).

  5. If you need to perform an action that you don't want to record in the macro, click the Pause Recorder button on the Stop Recording toolbar, perform the action, and then click the Resume Recorder button.

  6. When you've finished all the actions you want to record, click the Stop Recording button or double-click the REC indicator on the status bar to stop recording. (You can also double-click this indicator to start recording a macro.)

To play back the macro, open or activate the document you want to affect, choose Tools » Macro » Macros, select the macro in the listbox, and click the Run button. If you can't see the macro in the list, check the setting in the "Macros in" drop-down list. Choose "All active templates and documents" to see the full list of available macros.