Microsoft Word Macros: A Step-by-Step Guide
In this article
Microsoft Word macros let you automate repetitive tasks—from formatting headings to inserting standard clauses—by recording a sequence of actions or writing a short script. To get started, you need Word on Windows or Mac (the steps below are for the desktop app; the web version does not support macros). You also need the Developer tab enabled, and you should save your document as a macro-enabled file (.docm) so your macros are kept.
What You'll Need
- Microsoft Word desktop app (Windows or Mac). The browser version cannot run macros.
- A document you can experiment with—avoid using a critical file until you are comfortable.
- Basic familiarity with the ribbon and the Quick Access Toolbar.
Step-by-Step
- Enable the Developer tab. Go to File > Options > Customize Ribbon. In the right-hand list, tick the box next to Developer, then click OK. On Mac, go to Word > Preferences > Ribbon & Toolbar, tick Developer, and close the window. Menu labels can differ slightly by version, device, or region.
- Decide what to automate. Write down the exact steps you repeat—for example, applying Heading 1 style, adding a company footer, or inserting a table with specific column widths. Macros record keystrokes and menu choices, so know the sequence before you start.
- Record a macro. On the Developer tab, click Record Macro. Give it a name with no spaces (use underscores), choose whether to store it in the current document or in the Normal template (so it is available in all documents), and optionally assign a button or keyboard shortcut. Click OK to start recording.
- Perform the actions slowly and deliberately. Use the keyboard and ribbon as you normally would. Avoid correcting mistakes with the mouse if possible—every action is recorded. When finished, click Stop Recording on the Developer tab (or the small stop button on the status bar).
- Test the macro. Place your cursor where you want the actions to run, then click Macros on the Developer tab, select your macro, and click Run. Check the result. If it went wrong, you can delete the macro and record again—recording is often faster than editing the code.
- Save in the right format. If you stored the macro in the current document, save the file as a Word Macro-Enabled Document (.docm). If you stored it in the Normal template, it will be available in new documents, but you may see a security prompt when opening files—choose Enable Content only if you trust the source.
- Edit or view the code (optional). On the Developer tab, click Macros, select your macro, and click Edit to open the Visual Basic for Applications (VBA) editor. Here you can tweak the recorded steps or add logic. Close the editor to return to Word.
- Assign a shortcut or button (optional). To add a button to the Quick Access Toolbar, click the small arrow at the end of the toolbar, choose More Commands, select Macros from the drop-down, and add your macro. For a keyboard shortcut, go to File > Options > Customize Ribbon > Keyboard shortcuts: Customize, find your macro, and assign a key combination.
Common Mistakes
- Saving as .docx. Macros are stripped from standard .docx files. Always use .docm for documents that contain macros.
- Recording with the wrong selection. If you select text before recording, the macro may act only on that selection. Start with the cursor placed correctly and no text selected unless intended.
- Relying on the mouse for precise placement. Recorded mouse clicks can be unreliable. Use keyboard shortcuts (Ctrl+Home, arrow keys) where possible.
- Ignoring security prompts. Macros can carry malware. Only enable content from trusted sources, and never enable macros in files you received unexpectedly.
- Storing in Normal template unintentionally. Macros saved to Normal are available everywhere, which is convenient but can clutter your setup. Choose the storage location deliberately.
Tips
- Record a macro in a blank document first to test the sequence without affecting real work.
- Use descriptive names like Format_Heading or Insert_Footer so you can find them later.
- If you need to pause recording, click Pause Recording on the Developer tab; click it again to resume.
- Keep macros simple. A macro that does one thing well is easier to maintain than one that tries to do everything.
- Back up your .docm files. Macros are stored inside the document, so losing the file means losing the macro.
Troubleshooting
- The Developer tab is missing. Re-check the Customize Ribbon settings; on some managed work computers, an administrator may have disabled it.
- The macro does not appear in the list. Make sure you are looking in the correct document or template. Macros stored in Normal appear under “All active templates and documents” in the Macros dialog.
- Nothing happens when you run the macro. The macro may be waiting for a selection or may have been recorded with a different starting point. Try running it with the cursor in a plain paragraph.
- A security warning blocks macros. This is normal. Click Enable Content only if you created the file or trust its source. If the file came from the internet, consider using Trust Center settings to manage macro security—but do not lower security settings globally without understanding the risk.
- You need to remove a macro. On the Developer tab, click Macros, select the macro, and click Delete. This cannot be undone, so export or copy the code first if you might need it.
Frequently Asked Questions
Can I use macros in Word for the web?
No. Macros run only in the Word desktop app for Windows and Mac. The web version can open .docm files but will not execute macros.
Do macros work on both Windows and Mac?
Yes, but the VBA environment and some recorded actions can behave differently. A macro recorded on Windows may need adjustments on Mac.
How do I share a macro with a colleague?
Save the document as .docm and send that file. Your colleague will see a security prompt and must choose Enable Content to run the macro. Alternatively, export the VBA code as a .bas file from the Visual Basic editor and share that.
What is the difference between a macro and a template?
A template (.dotx or .dotm) stores styles, layout, and optionally macros for creating new documents. A macro is a set of automated actions stored inside a document or template.
Can a macro delete my work?
Yes—a poorly written macro can delete content or change formatting across a document. Always test on a copy first, and keep backups of important files.
Is it safe to enable macros in a file I downloaded?
Only if you trust the source. Macros can run malicious code. When in doubt, do not enable content; ask the sender to provide a macro-free version or explain what the macro does.