A macro is a series of commands that are recorded and saved, so that they can be easily run again on demand. If you have a series of repetitive tasks, recording a macro can save you a lot of time.
Before you can create or use macros, you’ll need to turn on the Developer tab.
- Click the File tab.
- Select Options.
The Word Options window opens.
- Click the Customize Ribbon tab on the left.
The column on the right controls which ribbon tabs are enabled.
- Check the Developer check box.
- Click OK.
The Developer tab now appears at the end of the ribbon.
Once you've enabled the Developer tab, you can change a document's security settings to allow macros to be used.
- Click the Developer tab.
- Click the Macro Security button.
Before you use macros, it's important to know that macros can be a security risk. Since they run outside code, running one from an untrustworthy source can infect your computer, or others on your network, with a virus.
- Choose the proper security level.
There are four levels of macro security:
- The first level disables macros entirely, blocking them without a notification. This option is the safest but doesn’t allow you to run macros at all—even macros you record yourself.
- The default setting blocks macros but displays a notification. This notification allows you to enable macros on a case-by-case basis. This option is safe, as long as you know that you can trust the macros you allow.
- You can automatically enable digitally signed macros. You'll still be prompted for most macros, but trusted macros will be allowed without a prompt.
- Finally, you can enable all macros without a prompt. This can be dangerous, so use this command with caution.
- Click OK.
The selected macro security setting is enabled.
When you have a repetitive series of tasks to perform, you can record those tasks as a macro.
- Place the cursor where you want to start recording the macro.
- Click the Record Macro button.
The Record Macro window opens, where you can set up the macro’s name, description, and triggering mechanism before you record it.
- Give the macro a name.
Notice that the macro will be saved to the Normal template, meaning that it will be available in other documents created using that template. If you need it saved to another template or document, make sure to specify that here.
Next, you can choose whether the macro gets triggered to run by a button that can be added to the Quick Access Toolbar, or a keyboard shortcut key combination. This lesson will cover adding a macro that uses a keyboard shortcut.
- Click the Keyboard button.
- Press the keyboard shortcut keys that you want to use.
Make sure to use a keyboard shortcut combination that won’t interfere with any other Word or system commands.
- Click Assign.
- Click Close.
The macro immediately begins recording.
- Record the macro.
While recording, the macro captures keystrokes and buttons clicked, but text selection made with the mouse will not be recorded. Use the keyboard to select text and move the cursor, if you want those actions recorded.
A Stop button will also appear on the status bar while a macro is recording.
- Click the Stop button when you’re finished recording.
The recording stops, and the macro is saved.
When you’ve recorded and saved a macro into a document, you can run it using the keyboard shortcut or Quick Access Toolbar button assigned to it when it was created. You can also view all the macros in a document and choose one to run directly.
- Click where you want to run the macro.
- Click the Developer tab.
- Click the Macros button.
All the macros in the current template are listed in the Macros dialog box. From here, you can run a macro, edit it, create a new one, or delete macros that you no longer need.
- Select a macro.
- Click the Run button.
Select a macro and click the Edit button to open the macro in the Visual Basic editor. From there, you can view the steps the macro uses, delete unneeded steps, or even change the properties of a step to customize the macro even more.
The selected macro is run.