Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Word's macro features uses VBA or Visual Basic for Applications to create programs that can be used within Word 2011. This feature was available in Word 2004, but was removed, much to the disappointment of Mac Word users, in Word 2008. Now it's back, giving Word users the ability to automate repetitive tasks within their documents. VBA and Word's macro feature are not simple topics. They're extremely complex. Entire books have been written about them.
So rather than go off on a tangent about a powerful feature that's beyond the needs of most Word users, I'll focus on the basics: using Word's Macro Recorder. In our example, we frequently receive plain text files from a client that we need to incorporate into formatted Word documents. Unfortunately, the text we receive includes paragraph marks at the end of each line, two spaces between sentences, and straight quotes rather than smart quotes. We can use Words Find and Replace feature to fix all of these problems, but doing so each time a file arrives is time-consuming and tedious.
Word's macro feature can help. Now if you think this sounds far fetched, it isn't. I get files like this from someone I work with all the time and this is one of the ways I deal with them. There are two main things to remember about using the Macro Recorder. First, you can't use the mouse to select anything within your document. Word will not recognize mouse selections. Any selection must be done with keyboard keys or other commands. Second, the Macro Recorder will record everything you do, including mistakes.
For that reason, it's a good idea to plan out the macro thoroughly before you begin. So let's give this a try. I'm going to pull down the Tools menu, come down to Macro, and choose Record New Macro. In the top box here you want to put in a name for the macro. So I'll just call it reformat. The name could be anything you like, but it can't include any spaces. Down below this box here you could put a description. I'm not going to do that for this. We don't really need it. And you can use this pop-up menu to determine where the macro should be stored.
If you expect to use the macro regularly in all your documents leave it set to All Documents (Normal). In this area up here you can assign the macro to either toolbars or keyboard. We'll assign it to a keyboard shortcut. So I'll click the Keyboard button and I get the Customize Keyboard dialog. The macro was already selected at the top of the dialog, so all I need to do is put a keyboard shortcut in here, and the way I do it is I type it in. Now I could type in Command+A but as you can see here that's already assigned to something else.
So what I need to do is find a keyboard shortcut that's not assigned to anything. I'm just going to press Delete to get rid of that and I know that Command+Option+Shift+A is not assigned to anything. You can see it says unassigned, so I'll use that. I'm going to click Assign and then click OK. From this point forward, Word is recording all the steps I do. The first thing I want to do is I want to apply the Normal style to the entire document. I can't select the document by dragging because I can't use the mouse, so I need to use a shortcut key or a menu command for that.
I know that pressing Command+A will select the entire document. So I'll do that. Next I want to apply the Normal style. So I'm going to pull-down the Format menu, choose Style, make sure Normal is selected here, and then click Apply, and that applies the Normal style to the entire document. Now at this point you may be seeing squiggly red underlines and squiggly green underlines under text. That's just the automatic spelling and grammar checkers doing their job. You can ignore them.
The next thing I want to do is position my insertion point at the beginning of the document. Again, I can't click. I need to use the keyboard. So I'm going to press the Up key on the keyboard and because the document is completely selected, that will position my insertion point at the beginning. Next, I'm going to start using Find and Replace to make some changes in this document. I want to keep the spacing between paragraphs like you see here, and that spacing is created by pressing Return twice. There are two paragraph marks in a row, and I want to keep that.
Later I'm going to tell Word to strip out the paragraph marks at the end of each line. Now I don't want it to take up the ones I want to keep, so what I'm going to do is replace them with something else first. So we'll start off by opening the Find and Replace dialog. I'll pull down the File menu, come down to Find and choose Advanced Find and Replace. that will open up this dialog. I'm going to pull it aside a little bit so we could see what we're doing here. Make sure you click the Replace tab, because we want to replace things.
The first thing we want to replace is those double paragraph marks. We want to put in a replace with phrase that's going to be not found anywhere else in the document. So to type in a paragraph mark in the Find and Replace dialog, it's ^p, and I want to find two consecutives ones, so I'll type in ^p again. I'm going to press Tab to go to the Replace with box, and in then I want to type in characters that will not be found anywhere else in the document. So I'll put in something like three @ signs.
Then I'll click Replace All. Word has made 30 replacements. I can press Return, which clicks OK, and that brings you back to this dialog. The next thing I want to do is replace the single paragraph marks that are left. Those are the ones that are at the end of each line. I want to replace those with a space. So I'm going to come up to the Find with box. I'm going to type in ^p. That's the single paragraph mark and I'll replace that with a space. So I'll type in a single space and Replace with.
And again, click Replace All. 77 replacements is fine, click OK. Now I want to replace those @ signs I typed in with two consecutive paragraph marks to get it back the way it was. So I'll find one, two, three @ signs, and select in the bottom box, make sure you select the space that's in there, and you want to replace that with two paragraph marks. So it's ^p^p. And Replace All again, and sure enough it's starting to look better.
Click OK. Now I want to go through and replace any instances of two consecutive spaces with one space. So two spaces there, one space there, Replace All. Great! Made some changes. Click OK. Now I want to replace the straight quotes with curly quotes. In Word in order to do that you make sure that curly quotes or smart quotes is turned on, which they are by default, and then you type in the quote you want to replace. So I want to replace single with single, and again, make sure the spaces are selected and deleted when you put those in. Click Replace.
It only made one replacement in the whole document. Click OK and then again for the double, double quote, double quote. Replace All. It made eight replacements and we're done. So I could dismiss this dialog and that's starting to look pretty good. The last thing we want to do is save this as a Word document. Remember it was originally a text document. So I'm going to go over the File menu, choose Save As, and then in this dialog that appears, I want to choose the folder I wanted to go into, which is folder CH22 in my instance.
I want to choose the Format I want, which is Word Document. I don't want to save it as a text file. We put in the file extension, so it won't overwrite the existing file in there. They have different file extensions. And I can click Save and now I'm done. So I need to turn off the Macro Recorder. I want it to stop recording and save that macro. Pull-down Tools, come down to Macro, choose Stop Recording. Now it's done, we can give it a try. So I'm going to close this document, get rid of this, get rid of this.
I'm going to erase the one that we just had. I'm just going to delete it so it doesn't interfere. And then I'm going to open this up in Word. I'll just drag it on top of Word's icon. When you open a text file in Word it asks file conversion information. This is a Mac OS file with this kind of formatting here. So I'll just click OK and that will open it up and now we'll try the macro. If you remember the keystroke, it was Command +Option+Shift+A. That's the one we gave it.
Again, you can give it anything you like. I'm going to press that. Word does the job. Let's scroll up to the beginning of the document and it's all done. Now that took a few minutes to do, but we saw how quickly Word could do it again. It's a real timesaver once you set it up. It's just one example of how you can use Word's Macro Recorder to automate tasks. Again, you need to think all your steps in advance and make sure you can complete them without using the mouse to select text.
Once your macro is saved to the Normal template it will be available in all documents.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 64853 Viewers
80 Video lessons · 124397 Viewers
52 Video lessons · 60322 Viewers
59 Video lessons · 46147 Viewers