Microsoft Office Tips for Word and Excel

How to Create and Use a Microsoft Word Macro

What is a Macro?

A Macro is a method of automating a series of actions. Macros can be used in both Microsoft Word and Microsoft Excel, but this tutorial will concentrate on Microsoft Word. Macros are like a very small program, however, they are even smaller than the most basic program or application.

Aren’t Macros “Viruses”?

A Macro is not a virus. It’s a program, in a sense (actually it’s smaller than a program). Macros for Microsoft Word and Excel are written in the Visual Basic scripting language (VB). Theoretically, if some unscrupulous person were to e-mail you a macro and you installed it – you could install a virus. However, Javascript, Java, Flash, Shockwave (older Flash), Frame .Net, and several other scripting languages that make the Internet work could also “hide” viruses. Just as you should avoid suspicious websites, always run anti-virus software, and run anti-spyware, and anti-adware programs on your computer – you shouldn’t install a suspicious “free” macro. But if you write the macros yourself in VB, or use the Macro Recorder in Word or Excel to create your own Macros – there shouldn’t be any problem and you shouldn’t encounter a virus. After all, Why would you put a virus in code you wrote yourself?

When to Use a Macro

It is important to give some thought as to what situations may be improved or made faster or more consistent by using Macros. Macros automate steps – to be worth it, it should be a fairly long, repetitive, series of steps. If you find yourself doing the same thing over and over, with no variation, a Macro might help you. The other key to using macros is that it must be the exact same series of steps – you cannot (easily) include a variable in a macro. So if you’re writing a phone list in Word but everyone’s name and phone number are different – that is not a good candidate for a Macro. Also, there should be several steps – if it’s just one or two, a Macro probably isn’t worth setting up.

There are other ways to automate formatting of text such as with Styles. And Find and Replace is a marvelous tool that can help and automate changing certain types of text formatting (such as removing double spaces after a period and replacing them with a single space.) You can also use a Macro to automate steps in a Find and Replace sequence.

When developing Macros, stick with repetitive tasks with several identical steps – but once set-up they can save you time.

How to Create a Macro

Creating a Macro is really very easy, although they are written in Visual Basic (VB), you don’t even need to know VB to create Macros. One of the easiest ways to create a Macro is by using Microsoft’s Macro Recorder.

  • In Microsoft Word 2010 and later, click the developer tab. If you don’t see the developer tab, do the following:
  •  Go to the File tab, then
  • Click Options, then
  • Click “Customize Ribbon”
  • Put a check mark in “Developer” and click “OK”
  • The Developer Tab should now be visible


  • Next, click the Macro Recorder button – be sure you know what steps to perform for your macro because once you hit the record button every action will go into your Macro.


For this lesson we will create a Macro to replace hard-coded line breaks with paragraphs marks. Why? Have you ever copied a professional article, or even a fanfic from on-line to Word for off-line reading – only to have it be only three and a half or four inches wide no matter what you do? The article or story has hard-coded line breaks at the end of every single line. To make the text flow, the first step is to get rid of the hard breaks. After the line breaks are removed, extra paragraph marks can be removed separately (and manually).

By hand (without a Macro) you remove a hard break by using Find and Replace.

  • Click Find (the binoculars)
  • Choose Replace… from the pull-down menu
  • Click More>>
  • Click Special and open it with the pull down menu


  • Click in “Find What” then click “Manual line break” in the Special Menu


  • Click in “Replace with” then click “paragraph mark”
  • Finally, click “Replace All”.
  • Once it’s run, it will tell you how many replacements it’s made. You can close out of Find and Replace.

To create a Macro using Recorder, press the Record button, do all the steps above, close out of Find and Replace, then click “End Record”. (If you want to know how many replacements were many each time you use the Macro stop recording with clicking “Replace All”. However, you’ll need to close “find and Replace” every time you run the Macro.)

The Macro dialogue will also ask you to name your Macro and if you want to assign it to a button or keyboard combination. I usually go with “button” and have the Macro on my Quick Access toolbar. When I’ve worked in Technical Writing and had ten or so Macros for different functions, our version of Word had a new Ribbon Group with all the Macros we used for work on it. But for a home user or small business, placing buttons on the Quick Access Toolbar is fine. And of course, if you would rather use a Keyboard Combo, that is fine too.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s