Understanding Microsoft Word Macros

Microsoft Word logo
Microsoft

For many Word users, the term "macro" strikes fear in their hearts, mainly because they do not fully understand Word macros and have most likely never created their own. Simply put, a macro is a series of commands that is recorded so it can be played back, or executed, later. 

Fortunately, creating and running macros isn't too difficult, and the resulting efficiency is well worth the time spent learning to use them. Keep reading to learn how to work with Macros in Word 2003. Or, learn how to record macros in Word 2007.

There are a couple different ways to create Word macros: The first, and easiest way, is to use the macro recorder; the second way is to use VBA, or Visual Basic for Applications. Further, Word macros can be edited by using the VBE, or Visual Basic Editor. Visual Basic and the Visual Basic Editor will be addressed in subsequent tutorials.

There are over 950 commands in Word, most of which are on menus and toolbars and have shortcut keys assigned to them. Some of these commands, however, are not assigned to menus or toolbars by default. Before you create your own Word macro, you should check to see if it already exists and can be assigned to a toolbar.

To see the commands available in Word, follow this quick tip to print out a list, or follow these steps:

  1. On the Tools menu, click Macro.
  2. Click Macros… from the submenu; you can also use the Alt + F8 shortcut key to access the Macros dialog box.
  3. In the dropdown menu beside the "Macros in" label, select Word Commands.
  4. An alphabetical list of the command names will appear. If you highlight a name, a description of the command will appear at the bottom of the box, under the "Description" label.

If the command you wish to create already exists, you should not create your own Word macro for it. If it doesn't exist, you should proceed to the next page that covers planning your Word macro. 

How to Create Effective Word Macros

The most important step in creating effective Word macros is careful planning. While it might seem a bit obvious, you should have a clear idea of what you want the Word macro to perform, how it will make your future work easier and the circumstances under which you intend to use it.

Otherwise, you may end up spending time creating an ineffective macro that you won’t use.

Once you have these things in mind, it is time to plan the actual steps. This is important because the recorder will literally remember everything you do and include it in the macro. For example, if you type something and then delete it, every time you run the macro Word will make the same entry and then delete it.

You can see how this will make for an sloppy and inefficient macro.

When you are planning your macros, here are some things to consider:

  • Plan the commands and the order in which you want the macro to perform them.
  • Know the shortcut keys for the commands you plan to use. This is particularly important for navigation; you will not be able to use the mouse for navigation within the document area when you are running the recorder. Further, you will create a leaner macro if you use a shortcut key rather than the arrow keys, as each keystroke will be included.
  • Plan for messages that Word might display and that will stop the macro.
  • Use as few steps as possible to keep the macro lean.
  • Do at least one test run before you start recording.

After you’ve planned your Word macro and done a run through, you are ready to record it.

If you’ve planned your macro carefully enough, recording it for later use will be the easiest part of the process. It is so easy, in fact, that the only difference between creating a macro and working on the document is that you have to press a few extra buttons and make a couple of selections in dialog boxes.

Setting Up Your Macro Recording

First, click Tools in the menu and then click Record New Macro... to open the Record macro dialog box.

In the box beneath "Macro name," type a unique name. Names can contain up to 80 letters or numbers (no symbols or spaces) and must begin with a letter. It is advisable to enter a description of the actions the macro performs in the Description box. The name you assign the macro should be unique enough that you remember what it does without having to refer to the description.

Once you have named your macro and entered a description, select whether you want the macro to be available in all documents or only in the current document. By default, Word makes the macro available to all your documents, and you will probably find that this makes the most sense. If you choose to limit the availability of the command, however, simply highlight the document name in the dropdown box below the "Store Macro in" label.



When you have entered the information for the macro, click OK. The Record Macro Toolbar will appear in the upper left corner of the screen.

Record Your Macro

The mouse pointer will now have a small icon that looks like a cassette tape beside it, indicating that Word is recording your actions. You can now follow the steps you laid out in the planning stage; once you are done, press the Stop button (it is the blue square on the left).

If, for any reason, you need to pause the recording, click the Pause Recording/Resume Recorder button (it is the one on the right). To resume recording, click it again.

Once you press the Stop button, your Word macro is ready to use.

Test Your Macro

To run your macro, use the Alt + F8 shortcut key to bring up the Macros dialog box. Highlight your macro in the list and then click Run. If you don’t see your macro, make sure the correct location is in the box beside the "Macros in" label. 

The purpose behind creating macros in Word is to speed up your work by putting repetitive tasks and complex sequences of commands at your fingertips. What could take literally hours to do manually only takes a few seconds with the click of a button.

Of course, if you’ve created a lot of macros, searching through the Macros dialog box will eat up a lot of the time you save. If you assign your macros a shortcut key, however, you can bypass the dialog box and access your macro directly from the keyboard—the same way you can use shortcut keys to access other commands in Word.

Creating Keyboard Shortcuts for Macros

  1. From the Tools menu, select Customize…
  2. In the Customize dialog box, click Keyboard.
  3. The Customize Keyboard dialog box will open.
  4. In the scroll box beneath the "Categories" label, select Macros.
  5. In the Macros scroll box, find the name of the macro to which you would like to assign the shortcut key.
  6. If the macro currently has a keystroke assigned to it, the keystroke will appear in the box below the "Current keys" label.
  7. If no shortcut key has been assigned to the macro, or if you would like to create a second shortcut key for your macro, click in the box below the label "Press new shortcut key."
  1. Enter the keystroke you would like to use to access your macro. (If the shortcut key is already assigned to a command, a message will appear beneath the "Current keys" box that says "Currently assigned to" followed by the name of the command. You can reassign the keystroke by continuing, or you can select a new keystroke).
  2. In the dropdown box beside the label "Save changes in" select Normal to apply the change to all documents created in Word. To use the shortcut key only in the current document, select the document name from the list.
  3. Click Assign.
  4. Click Close.
  5. Click Close on the Customize dialog box.