Mobile Number Tracker
Trace Mobile Number Earn Money Online
© TechWelkin.com

How to Record, Write and Run a Macro in MS Word

Our tips on MS-Word make your life easier and increase your productivity at work.
Samyak Lalit | September 18, 2012 (Last update: July 31, 2017)

Samyak Lalit is an Indian author and disability rights activist. He is the principal author and founder of projects like TechWelkin, WeCapable, Viklangta, Kavita Kosh among many others.

Before we learn how to write macro in MS Word, let’s understand what exactly is a macro. Well, macro is a set of instructions which automatically execute sequentially (one after the other). For example, sometimes you repeatedly do several tasks, like selecting all the text in document (with CTRL + A), then making it all italic (with CTRL + I), then go to font formatting and make all this text as blue. You can record these three tasks in a macro and then give this macro a name. Afterwards, you would just need to run this macro and all these three instructions will be automatically executed.

You can make macros in two ways. If you just want MS Word to track and record your actions, you can Record a Macro. Secondly, if you need to write more complex instructions, you can program a macro. Let’s look at both of these options.

Record a Macro in MS Word

MS Word (and all other software in MS Office package) allow you to record your actions and then execute them as a single command. Before you begin recording of a macro, I would suggest that you become very sure what you want to do and how you want to do because every action of your will be recorded in macro. Let’s understand it by an example:

  1. Open a document and begin recording a macro. Now you take the following steps:
  2. Select all text in the document (by pressing CTRL + A)
  3. Make all the selected text italic (by pressing CTRL + I)
  4. Make all the selected text orange  (OOPS! But, you wanted to make it blue!)
  5. You again select the text (by pressing CTRL + A)
  6. Make all the selected text blue
  7. Stop macro recording.

Macro will record all these steps. You can not remove step 4 and 5 from the macro recording. When you will run this macro, you’ll get all the desired result but macro will also go through step 4 and 5… that is to say that the macro will make the same mistake as you did and then it will correct the mistake just the way you did.

Did you get the point? Once you start recording a macro, ALL of your actions are recorded irrespective of whether they are wrong or right.

That is why you it is better to decide what exactly you want to record. If macro recording is going to be long, it is advisable that you practice the steps to perfect them before beginning the recording.

To record a macro, open the MS Word document and go to View menu. There you’ll see Macro option. Clicking on this will give you option to Record Macro.

When you choose to record a macro, MS Word will ask you to give the macro a name. This name will identify the macro for running it.

Once recording is done, go back to View > Macro > Stop Recording to end the recording.

How to Run a Macro

Having done with recording, now it is time to see how your new macro works.

Go to View > Macro > View Macros

Macros box will open. Select the name you’ve just given to your macro. And then click the Run button.

You’ll see that MS Word will execute all the actions that you had recorded.

Our tips on MS-Word make your life easier and increase your productivity at work.
How to Write a Macro

If you’re a programmer, you can also write more complex instructions to be executed as a macro. But first, you may want to see an example. With VBA macro for MS Word, for example, you can do multiple find and replace operation in one go.

Now here is how you can write a VBA macro:

In order to write a Visual Basic program to run in MS-Office packages (like Word, Excel, PowerPoint, Access etc) you need an editor. Microsoft has provided you with one. To bring this editor to the fore take the following steps. Here I assume that you are working in MS-Word.

In Word 2007 and above, click on the Office button (round orb like button in top left corner) and then click on the Word Options button given at the bottom of the menu.

A dialog box will appear. Go to the Popular tab and select the “Show Developer tab in the Ribbon” check box. Click OK.

SEE ALSO: My compilation of MS-Word Tips and Trick

Now on the ribbon, you will see Developer tab. Go to this tab and you will see a button to launch Visual Basic Editor.

In the Editor, you can start a new module and write your code in there. Then save the module. Remember, VBA modules created in Word are saved as documents.

Once you have written and saved the module, you can run it by opening the saved document and going to the View tab on ribbon. Then go to Macros button and select View Macros. A list of macros associated with the document will appear and you can select and run the macro you desire.

This was all the basic information about how to record, write and run a macro in MS Word. Please let me know if you have any question about this topic. I will be glad to try and help you. Thank you for using TechWelkin!

© TechWelkin.com

One response to “How to Record, Write and Run a Macro in MS Word”

  1. suresh k says:

    I have word doc contains alphanumeric words where as I want to do superscript and subscript for numeric i.e., example word is like this “adcf123 nmesc456” want to conver the 1 is superscript and 2 is subscript and 3 is again superscript and 4 is superscript and 5 is subscript and 6 is superscript. This should be done without highlighting automatically. If it is possible please provide the solution.

Leave a Reply

Your email address will not be published. Required fields are marked *