| | Product Information Help and How-to Training Templates Related Products and Technologies Support and Feedback Technical Resources Additional Resources | Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.
In Microsoft Office Word 2007, you can automate frequently used tasks by creating and running macros. A macro is a series of commands and instructions that you group together as a single command to accomplish a task automatically.
Typical uses for macros are:
- To speed up routine editing and formatting
- To combine multiple commands — for example, to insert a table with a specific size and borders, and with a specific number of rows and columns
- To make an option in a dialog box more accessible
- To automate a complex series of tasks
You can record a sequence of actions, or you can write a macro from scratch by entering Visual Basic for Applications (Visual Basic for Applications (VBA): A macro-language version of Microsoft Visual Basic that is used to program Microsoft Windows-based applications and is included with several Microsoft programs.) code in the Visual Basic Editor (Visual Basic Editor: An environment in which you write new and edit existing Visual Basic for Applications code and procedures. The Visual Basic Editor contains a complete debugging toolset for finding syntax, run-time, and logic problems in your code.).
Note To work with macros in Office Word 2007, you need to show the Developer tab.
What do you want to do?
Show the Developer tab
- Click the Microsoft Office Button
, and then click Word Options.
- Click Popular.
- Under Top options for working with Word, select the Show Developer tab in the Ribbon check box.
Note The Ribbon is a component of the .
Top of Page
Record a macro
- On the Developer tab, in the Code group, click Record Macro.

- In the Macro name box, type a name for the macro.
Note If you give a new macro the same name as a built-in macro in Office Word 2007, the new macro actions will replace the built-in macro. To view a list of built-in macros, on the Developer tab, in the Code group, click Macros. In the Macros in list, click Word Commands.
- In the Store macro in box, click the template (template: A file or files that contain the structure and tools for shaping such elements as the style and page layout of finished files. For example, Word templates can shape a single document, and FrontPage templates can shape an entire Web site.) or document in which you want to store the macro.
Important To make your macro available in all documents, be sure to click Normal.dotm.
- In the Description box, type a description of the macro.
- Do one of the following:
- Perform the actions that you want to include in the macro.
Note When you record a macro, you can use the mouse to click commands and options, but not to select text. You must use the keyboard to select text. For more information about selecting text by using the keyboard, see Select text.
- To stop recording your actions, click Stop Recording in the Code group.
Change the keyboard shortcut for a macro
- Click the Microsoft Office Button
, and then click Word Options.
- Click Customize.
- Next to Keyboard shortcuts, click Customize.
- In the Categories list, click Macros.
- In the Macros list, click the macro that you want to change.
- In the Press new shortcut key box, type the key combination that you want to choose.
- Check the Current keys box to make sure that you aren't assigning a key combination that you already use to perform a different task.
- In the Save changes in list, click the option that matches where you want to run your macro.
Important To make your macro available in all documents, be sure to click Normal.dotm.
- Click Close.
Top of Page
Run a macro
- On the Developer tab, in the Code group, click Macros.

- In the list under Macro name, click the macro that you want to run.
- Click Run.
Top of Page
Write a macro from scratch
- On the Developer tab, in the Code group, click Macros.

- In the Macro name box, type a name for the macro.
Note If you give a new macro the same name as a built-in macro in Office Word 2007, the new macro actions will replace the built-in macro. To view a list of built-in macros, click Word Commands in the Macros in list.
- In the Macros in list, click the template (template: A file or files that contain the structure and tools for shaping such elements as the style and page layout of finished files. For example, Word templates can shape a single document, and FrontPage templates can shape an entire Web site.) or document in which you want to store the macro.
To make your macro available in all documents, be sure to click Normal.dotm.
- Click Create to open the Visual Basic Editor.
After you open the Visual Basic Editor, you may want more information about working with Visual Basic for Applications. For more information, click Microsoft Visual Basic Help on the Help menu or press F1.
Top of Page
See it in action
Watch these videos to see how to create, edit, and run a macro.
Enable the Developer tab and prepare to record a macro
 |
Play Demo  See how to enable the Developer tab, prepare a macro, assign a button, and begin recording
|
Record, pause, save, and run
 |
Play Demo  See how to record a macro while pausing and resuming, and then save and run the results.
|
Edit the macro
 |
Play Demo  Watch as a macro is edited in Microsoft Visual Basic and saved.
|
Assign a button or keyboard shortcut
 |
Play Demo  Assign a button or a keyboard shortcut to an existing macro.
|
Top of Page
|