Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
If you have a series of steps that you complete in a number of different documents, or that you complete a number of times within a document or document set, that group of steps is a great candidate for a Macro. Macros are bundles of Visual Basic code that tell Word how to complete a particular task. While you can create Macros manually using the Visual Basic Editor, it's much easier to use Microsoft Word's built-in Macro Recorder to create and save your Macros.
Macros are created to solve a problem. The problem that I have here is that I have a lot of documents that were created a few years ago. At that time, when people typed in text and got to the end of a line, they would press the Enter key twice. When they got to the end of a sentence, they would press the Spacebar twice. They did those things because the software wasn't smart enough to automatically increase the space at the end of a paragraph, or to replace an end space with an em space at the end of a sentence.
Now, I have too much space in my document so that if I change to one of the newer styles, for example, something like modern, look at all of the space in this document, because we have not just the space that the original typist entered, but the space that Microsoft Word automatically puts into this document. So, rather than tell Word to quit doing what it does to style this document, I need to just get rid of all of the extra spaces and all of the extra carriage returns at the ends of paragraphs.
Rather than use this document, I have created a test document to allow us to create and test our Macro. So I am going to switch to that document now, because there is no reason to turn my mission-critical documents into guinea pigs. So here's my Test Document. It has the same kind of attributes as the document that I want to be able to reformat. So the first thing we are going to do is make sure that the conditions when our Macro runs are actually reflected in this document and in the current state of the document. Like my other document that I want to use this Macro on, I have two spaces at the end of sentences, two Carriage Returns at the end of paragraphs.
I don't have anything selected here, which is fine because selecting the entire document is going to be the first thing I do in my Macro. Two ways that I can find the command to record a Macro, if I have the Developer tab available. It's in the Code group, under Record Macro. If you don't have the Developer tab displayed, under View > Macros > Record Macro, you can click and either of those will open this same Record Macro dialog box. The first thing I need to do is give the Macro a decently descriptive name.
I'm going to call this SingleSpaceSingleCRReformat. Next, I want to provide a Description that says "This Macro converts double spaces and double carriage returns found in legacy documents to single spaces and CRs." I'm also going to make a note about who I am.
I am actually going to sign to this Macro in a way to say Created by me and how to find me. When I open a document that has Macros that aren't signed, that I can't necessarily tell what they do without going and opening the Visual Basic Editor, I get nervous, and I don't want to necessarily use that document or those Macros. So this is a way that at least people in the organizations that I work with who'll open this Macro would go yeah! We know who this person is.
Finally, two different locations to store my recorded Macro in, and I set those upfront. First, if this is a Macro that I want a used with one document only and I want the Macro to travel with the document, I'll save it in the document itself. For example, I could create a Macro that would sort a table in a document. Well, it's specific to that table. So I'll store in that document. But I want to create a Macro that I can use for a wide range of documents. So, I'm going to store it globally in Normal.dotm, which loads every time Microsoft Word is launched.
When I click OK, the Macro recorder begins running. You'll notice that my pointer changes so it has a small icon. I believe that's a cassette tape. I have to use some of my keyboard skills now because while we are just recording, and the pointer is that recorder icon, the Context menu is not enabled. So, when I right-click, nothing happens. I'll need to find another way to select all my text, like Ctrl+A. So, I've just recorded selecting all the text.
Now I'm going to choose the Home tab and click Replace to open the Find and Replace dialog box. There are two things I want to find. First, I want to find places where a space was typed twice. 1, 2 and replace everyone of those with one space I will replace them all at one time in my document. It says Word has done this 9 times. Do you want to search the remainder? This is sort of boilerplate text. We selected the whole document. So, there really is no remainder, and we'll simply say No.
Thank you for the replacements. So, now we don't have the extra space here. But we still have the two carriage returns. We want to search again, and I can't simply press the Enter key here. I actually need to include the character that's the Paragraph Mark. So, I'm going to click More. So I'll find the Paragraph Mark here where it says Special. Now I already have two spaces that I typed in this field. So I want to select those first and then say look for a Paragraph Mark followed by another Paragraph Mark.
So, that's all that's here. When I click in the Replace With Field, it still has the space from last time too. This is tricky stuff. So we want to make sure that we don't have that space here anymore, and that we replace two Paragraph Marks with one Paragraph Mark. I am going to click Replace All. It says 9 replacements were made. That makes sense. There's nine paragraphs. I don't need it to search anything else. Now, what I have is my document with only one carriage return at the end of each line, only one space between sentences.
I'm happy with this. I could end of my Macro now, but I'd like to end my Macro with this dialog box closed. So we are going to click Close to close the dialog, and then I'm going to stop the Macro Recorder. Three ways to do it. First, there is a button that I can click in the status bar while a Macro is recording. I can also go to the Developer tab > Stop Recording or to the View tab > Macros > Stop Recording. We are all done recording our Macro.
Now, I want to test it. I'm going to go back up to the two replacements that were made and undo them. Now my document is back the way it was before. I'm going to test my Macro. Either on the Developer tab, I can go to Macros, or on the View tab, I can go to Macros > View Macros. Here is my Macro and I want to Run it. It says Word has reached the end of the document. 9 replacements were made. So, this is my first dialog. Do I want to continue searching? No.
Here is my second one. No. There is my document. So, I can play this Macro back any time I want to, in any document I like. Are you tired of following the same steps and doing the same old grind with a series of documents? Just record a Macro, and let Microsoft Word do the necessary, but often mindless tasks in your document workday.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.