Word Macros

Macros are routines that you create to perform a task or set of tasks. They are not reactive like event handlers. You purposely execute a macro because you want Word to do something for you.

Recording Macros

The easiest way to create a macro (although not always the most efficient way) is to let Word record a series of actions you perform right in the interface. To do this, choose Tools Macro Record New Macro. This opens the Record Macro dialog (Figure 18-1).

Setting up to record a new macro

Figure 18-1. Setting up to record a new macro

Give the macro a name and click OK to start recording. While the macro is being recorded, a toolbar pops up with controls to stop the recording. If you want, you can use the Record Macro dialog to quickly assign the new macro to a toolbar button (this opens the Tools Customize dialog, which is covered in Chapter 3 ) or to a keyboard shortcut. You can also control where the macro is saved (the default is normal.dot) and give it a description.

Using Macros

You can view and manage macros you’ve created (either by recording or writing the code yourself ) by selecting Tools Macro Macros from the Word window (not the editor), or by hitting Alt-F8. This brings up the Macros dialog in Figure 18-2. Use the dialog to run a macro, open a macro in the VBA Editor, create a new macro, or delete an existing one.

Figure 18-2. The Macros dialog

Put Macros on Your Toolbars

To get easy ...

Get Word 2000 in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.