Javatpoint Logo
Javatpoint Logo

How to create a macro in Word document

Macro is a series of commands and instructions that you combine together as a single command to complete a task automatically.

Follow the below methods to create a macro in Word document -

Method 1: Record a macro using the Button option

Microsoft Word has the ability to record and run macros to improve the efficiency of the document.

Note: You can also add macros in Microsoft Excel.

There are the following steps to record a macro in Microsoft Word -

Step 1: Open the new or an existing Word document.

Step 2: Click on the View tab on the Ribbon and click on the drop-down icon associated with the Macros in the Macros section.

How to create a macro in Word document

Step 3: Click on the Record Macro from the drop-down menu.

How to create a macro in Word document

Step 4: A Record Macro dialog box will appear on the screen in which do the following -

  1. Enter the Name for the macro in the Macro name text field.
  2. To use the same macro for the further document, click on the All Documents (Normal.dotm) option from the Store macro in drop-down menu.
  3. Click on the Button icon in the Assign macro to section to run your macro.
How to create a macro in Word document

Step 5: A Word Options window will appear on the screen with highlighted Quick Access Toolbar at the left pane.

  1. Click on the new macro name (Normal.NewMacros.MyMacro) on the left side of the screen.
  2. Click on the Add button to add the macro on the Quick Access Toolbar at the right side of the screen.
  3. Click on the Modify button, as shown in the below screenshot.
How to create a macro in Word document

Step 6: Select macro that you want to record from the Modify Button dialog box, type the Display name, and click on the OK button.

How to create a macro in Word document

Step 7: Click on the OK button at the Word options window.

Step 8: Now, click on the View tab and click on the Macros drop-down menu. Click on the Stop Recording Macro from the drop-down menu.

How to create a macro in Word document

Now, you can see that recorded macro will appear on the Quick Access Toolbar.

How to create a macro in Word document

Method 2: Record a macro using keyboard option

Follow the below steps to record a macro using keyboard option -

Step 1: Open the new or an existing Word document.

Step 2: Go to the View tab -> Macros and select Record Macro from the drop-down menu.

How to create a macro in Word document

Step 3: A Record Macro dialog box will appear on the screen in which do the following -

  1. Enter the Name for the macro.
  2. To use the same macro for the further document, click on the All Documents (Normal.dotm) option from the Store macro drop-down menu.
  3. Click on the Keyboard icon in the Assign macro to section to run your macro.
How to create a macro in Word document

Step 4: A Customize Keyboard dialog box will appear on the screen. Press any combination of shortcut keys in the Press new shortcut key dialog box. Click on the Assign button.

Note: In our case, we are going to use the Ctrl+Shift+M key.

How to create a macro in Word document

Step 5: Once you click on the Assign button, Pressed combination of keys will appear in the current key text box. Click on the Close button, as shown in the below screenshot.

How to create a macro in Word document

Step 6: Perform the action that you want to record.

Step 7: Click on the View tab on the Ribbon and select on the Stop Recording from the Macros drop-down menu.

Run a macro

1. Go to View -> Macros and select View Macros from the drop-down menu.

How to create a macro in Word document

2. A Macros dialog box will appear on the screen. Select a Macro list that you want to run from the Macro name:.

3. Click on the Run button, as shown in the screenshot below.

How to create a macro in Word document

Add a macro button to the Ribbon

Adding a macro button to the Ribbon helps you to easily access the macro in the Word document.

Follow the below steps to add a macro button to the Ribbon -

Step 1: Click on the File tab at the top left corner of the screen. A list of File options will appear on the screen. Click on the Options tab.

How to create a macro in Word document

Step 2: A Word Options dialog box will appear on the screen. Click on the Custom Ribbon at the left pane of the screen.

Step 3: Click on the Macros under the Choose Command from the section. Click on the New Tab and then Click on the Add. A macros icon will appear on the screen.

How to create a macro in Word document

Step 4: Right-Click on the Macros and select Rename form the drop-down menu.

Step 5: A Rename dialog box will appear on the screen. Select the symbol according to your requirement. Enter the symbol name in the Display name text box and click on the OK button.

How to create a macro in Word document

Now, you can see that macro is added to the Ribbon.

How to create a macro in Word document





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA