Recording a Macro
If
you find yourself repeating the same set of steps over and over, you
can record a macro. Macros can run several tasks for you at the click of
a button. When you turn on the macro recorder, Word records every mouse
click and keystroke action you execute until you turn off the recorder.
You can even record formatting changes to charts and other objects (New!).
Then you can “play,” or run, the macro whenever you want to repeat that
series of actions—but Word will execute them at a much faster rate. The
macro recorder doesn’t record in real time, so you can take your time
to correctly complete each action.
Record a Macro
- Click the Developer or View tab.
- Click the Record Macro button.
Timesaver
To quickly start or stop a macro recording, click the Record icon or Stop Record icon on the Status bar (left side).
- Type a name for the macro.
- Assign a shortcut key to use a keystroke combination or assign a button to run the macro.
- Click the Store macro in list arrow, and then select a location.
- All Documents. The macro is available whenever you use Word.
- Documents Based On. The macro is available in documents based on this document.
- This Document. The macro is available only in this document.
- If you want, type a description.
- Click OK.
- Execute the commands or actions you want to complete the task.
- Click the Stop Recording button.
Creating a Macro
If you
find yourself repeating the same set of steps over and over, or if you
need to add new functionality to Word, you could create a macro. If you
find it difficult to record a macro, you can create one using a
programming language called Microsoft Visual Basic for Applications
(VBA). With VBA, you create a macro by writing a script to replay the
actions you want. The macros for a particular document are stored in a
macro module, which is a collection of Visual Basic codes.
Create a Macro
- Click the Developer or View tab.
- Click the Macros button.
- Type a name for the macro.
- Click the Macros in list arrow, and then click All active templates and documents or the document to which you want the macro stored.
- Click Create.
The Microsoft Visual Basic window opens.
- Click the Module window (if necessary), and then type new Visual Basic commands, or edit existing ones.
- To run the macro, press F5.
- When you’re done, click the Save button, click the File menu, and then click Close and Return to Microsoft Word.