How to insert macros into Microsoft Word 2016 and 2019 documents?


Here’s a question from our reader, Krish: 

I am a teacher and I am using Word 2016 to write important documents. I repeatedly need to change the font and size for the paragraphs. Is there a way to change them to my preferred font on one click?

Here’s our answer:

To set same font of same size with justified text we can use Macro in Microsoft Word 2016. We will discuss how to record macro and set them on one click in Word.

How to insert a macro to Word 2016



  • Enable the developer Tab
  • Hit Developer tab and in the Code panel, we’ll see the Macros and Record macro.

2018-01-13 23_27_51-Document1 - Word

  • Now, click on the Record macro button (This invokes the macro recorder function in Word)

2018-01-13 23_28_49-

  • Set the name for the macro and add description for the macro.

2018-01-17 14_06_44-Record Macro

Now we’ll assing the macro to a keyboard key or button


Executing the macro can be done in three ways. They can be assigned using button, keyboard and also we can execute them manually.

Assign your new macro to buttons

  • Click on the Button icon to add a button to Word’s Quick Access Toolbar.

2018-01-13 23_31_33-Record Macro

  • Now, select the macro you just created and click Add to add the button to the Quick Access Toolbar.

2018-01-13 23_35_16-Word Options

  • Click on the Modify icon to select new icon and to rename and click OK.

2018-01-13 23_36_11-Word Options

  • Now your Macro will start recording, so now it’s time to work on your text and formatting.
  • After finishing working on the template, click Stop recording.
  • If needed we can even click pause recording and resume recording to work later.

2018-01-13 23_37_24-Document1 - Word

  • After recording the macro you’ll notice the new icon in your Quick Access toolbar (in your screen upper left side)

2018-01-13 23_39_08-Document1 - Word

Using Keyboard:

  • Click on the keyboard icon to add a shortcut for the template.

2018-01-13 23_39_57-Record Macro

  • In the Press new shortcut key, press and hold the Ctrl/Alt key and press any of the letter keys to assign it to display the template.
  • Click Assign and select Close.

2018-01-13 23_41_12-Customize Keyboard

  • Now your Macro will start recording, so it’s time to work on your text and formatting.
  • After finishing working on the template, click Stop recording.
  • If needed we can even click pause recording and resume recording to work later.

 

2018-01-13 23_37_24-Document1 - Word

  • Now, whenever we press the assigned key in the word document, your macro will be executed and the template will be added.

Manually running your macro

  • After the recording is finished, click the Developer tab and select Macros in the code option.

2018-01-13 23_43_01-

  • Here we can find the macros that we have created so far.
  • Now, click on the macro that has to be executed and select Run.

2018-01-17 14_08_59-Macros

  • Thus a macro can be executed manually.

Creating a macro using VBA (Visual Basic for Applications)

If you are an expert in Visual Basic we can edit the macros and write programs to automate various kinds of works using VBA.

Aside Note: FYI – some of the Microsoft Office applications, such as Powerpoint and Outlook, do not have built in macro recorders. Therefore, writing VBA is mandatory for writing Powerpoint macros and automating Outlook.

  • To edit a macro, click on the Developer tab and select Macros in the code option.
  • Click on the macro and select Edit.

2018-01-17 14_09_51-Macros

Example

Coming back to our reader’s question. Let us create a macro in Word 2016 that will help us format a paragraph font to Times New Roman, size 14 and justified alignment.

Let’s get going:

  • From the Developer tab, start a recording your macro

2018-01-13 23_28_49-

  • Enter the name, description and selected Button in the Assign to macros.

2018-01-17 14_06_44-Record Macro

  • Modify the Macro Name and icon.

2018-01-17 14_23_58-Word Options

  • Now, selected the texts and changed the font to Times New Roman, size to 14 and clicked Justify.

2018-01-17 14_24_24-Document1 - Word

  • Stop your recording.
  • You’ll see your assigned Macro icon in the Quick Access toolbar.
  • So whenever the text is selected and your macro button is clicked, it will be changed to our preferred font & size.

 

Leave a Comment: