How to Create a Macro in Word | CustomGuide

How to Create a Macro in Word

How to Create and Use Simple Macros in Word

How to Create a Macro in Word

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.

Show the Developer Tab

Before you can create or use macros, you’ll need to turn on the Developer tab.

  1. Click the File tab.
    Forms
  2. Select Options.
    Forms

    The Word Options window opens.

  3. Click the Customize Ribbon tab on the left.

    The column on the right controls which ribbon tabs are enabled.

  4. Check the Developer check box.
  5. Click OK.
    Forms

The Developer tab now appears at the end of the ribbon.

Enable Macros

Once you've enabled the Developer tab, you can change a document's security settings to allow macros to be used.

  1. Enable the Developer tab in Word Options.
  2. Click the Developer tab.
  3. 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.

    Create and Use Simple Macros

  4. 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.
  5. Click OK.
    Create and Use Simple Macros

The selected macro security setting is enabled.

Record a Macro

When you have a repetitive series of tasks to perform, you can record those tasks as a macro.

  1. Place the cursor where you want to start recording the macro.
  2. 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.

  3. 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.

  4. Click the Keyboard button.
    Create and Use Simple Macros
  5. 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.

  6. Click Assign.
  7. Click Close.

    The macro immediately begins recording.

    Create and Use Simple Macros

  8. 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.

  9. Click the Stop button when you’re finished recording.
    Create and Use Simple Macros

The recording stops, and the macro is saved.

Run a Macro

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.

  1. Click where you want to run the macro.
  2. Click the Developer tab.
  3. 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.

  4. Select a macro.
  5. 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.

  6. Click the Run button.
    Create and Use Simple Macros

The selected macro is run.