Understanding Macros in Microsoft Word

Save time by creating and using Word Macros

Woman working on laptop holding coffee mug.

 Martine Savard / Pexels

PRODUCT DISCLOSURE $

A macro is a series of commands that is recorded so it can be played back, or executed, later. Creating and running macros isn't too difficult, and the resulting efficiency is well worth the time spent learning to use them. This tutorial covers macros in Word 2003. If you have a later version, you can record macros in Word 2007, and create macros in Word 2010 and later.

Creating Macros

There are a couple of 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.

There are more than 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 these steps:

  1. Select the Tools menu and choose Macro.

  2. Select Macros from the submenu.

    You can also use the Alt + F8 shortcut key to access the Macros dialog box.

    Screenshot of Macro in Tools menu in Word 2003
  3. Select Word Commands in the drop-down menu beside Store Macro in.

  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 duplicate it with your own Word macro. If it doesn't exist, proceed with creating your Word macro. 

Planning 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 remember everything you do and include it in the macro. For example, if you type something and then delete it, every time you run that macro, Word will make the same entry and then delete it, making a 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.
  • Plan for messages that Word might display and that will stop the macro.
  • Use as few steps as possible to keep the macro efficient.
  • 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

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). Once you press the Stop button, your Word macro is ready to use.

  1. First, select the Tools menu and choose Record New Macro... to open the Record Macro dialog box.

  2. Type a unique name in the box beneath Macro Name and enter a description of the actions the macro performs in the Description box.

    Names can contain up to 80 letters or numbers (no symbols or spaces) and must begin with a letter. The name you assign the macro should be unique enough that you remember what it does without having to refer to the description.

    Screenshot of Record Macro dialog box
  3. Select whether you want the macro to be available in all documents or only in the current document. If you choose to limit the availability of the command, highlight the document name in the Store Macro in drop-down box.

    By default, Word makes the macro available to all your documents, and you will probably find that this makes the most sense.

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

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.

Test Your Macro

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.

  1. To run your macro, use the Alt + F8 shortcut key to bring up the Macros dialog box.

  2. Highlight your macro in the list and then select Run.

  3. If you don’t see your macro, make sure the correct location is in the Macros in box. 

Creating Keyboard Shortcuts for Macros

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 in the same way you can use shortcut keys to access other commands in Word.

  1. From the Tools menu, select Customize.

    Screenshot of Customize in Tools menu
  2. In the Customize dialog box, select Keyboard. The Customize Keyboard dialog box will open.

    Screenshot of Keyboard button in Word 2003 Customize dialog box
  3. In the Categories scroll box, select Macros.

    Screenshot of Macros in Customize Keyboard dialog
  4. In the Macros scroll box, find the name of the macro to which you would like to assign the shortcut key.

    Screenshot of Macros list in Customize Keyboard dialog box
  5. If the macro currently has a keystroke assigned to it, the keystroke will appear in the box below the Current keys label.

  6. If no shortcut key has been assigned to the macro, or if you would like to create a second shortcut key for your macro, select the box below Press new shortcut key.

    Screenshot of Press New Shortcut Key in Customize Keyboard
  7. 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 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.

  8. In the Save changes in drop-down box, 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.

  9. Select Assign.

  10. Select Close and then choose Close on the Customize dialog box.