Wednesday, June 15, 2011

Word Tip Wednesday: Macros


Update 6/7/13: There is an error in this tutorial regarding the highlight feature. There are notes in the comments on the correct way to do it. I will be updating the post soon. Thanks goes to Serena Yung for pointing out that it wasn't working. :)

Today’s topic will be easier if you’re familiar with  Find and Replace, since I will be using those as part of my example.

Macros might seem a little scary, but once you understand what they are and how they work, I think you’ll find they’re actually quite easy to use and very useful, especially during revisions. Basically, it’s a recorded set of steps that can be accessed by a shortcut key, a button on the toolbar, or by selecting from a list.



With this feature, I recommend reading through all the instructions before trying any of it. It will probably be less confusing that way.



The macro options are under the Developer tab.* By default, this tab is turned off in MS Word 2007, so first, you’ll need to turn it on. To do this, click the Office button in the top left corner (Figure 1).

Figure 1

Select Word Options at the bottom of the menu (Figure 2).

Figure 2

In this menu (Figure 3), select Popular in the left column and check the box next to Show Developer tab in the Ribbon. Then click OK.

Figure 3

You should now have the Developer tab in your Ribbon (Figure 4).

Figure 4

First, click the Record Macro button (Figure 5).

Figure 5

This menu will pop up (Figure 6). Enter a name in the Macro name: box. You can also add a description in the bottom box if you want.

Under Store macro in: you can choose to have it apply to all documents or just the one you are currently working with.

Figure 6

Under Assign macro to (Figure 6), you can choose to access the macro through a Button (Option 1) on your Quick Access toolbar or through a Keyboard shortcut (Option 2). If you don’t select one of these options and just click OK from this menu, it will immediately begin recording your macro. In this case, after you have recorded your macro, you will have to go to the Macros button (Figure 7) under the Developer tab and select it from a list (Figure 8) and click Run every time you want to use it (Option 3).

Figure 7

Figure 8

Note: This window (Figure 8) is also where you go to Edit your macros, but editing macros requires editing code, so unless you’re familiar with code, I wouldn’t attempt this. If there is problem with one of your macros, the easiest thing will probably be to Delete the macro and record it again.

Option 1: In the Record Macro window (Figure 6), choose Button under Assign macro to, it will go to this screen (Figure 9). Select the macro from the list in the left column, click Add>> and it will add it to the right column, which lists all the buttons in your Quick Access menu (this shows to the right of your Office button (Figure 1)). You can change the icon for the macro by selecting the macro and clicking Modify. Then click OK to begin recording your macro.

Figure 9

Option 2: In the Record Macro window (Figure 6), choose Keyboard under Assign macro to (Figure 6), and it will go to this screen (Figure 10). In the Press new shortcut key: box, press the keys you want to assign to the macro (pressing the Alt key at the same time as another key will enter “Alt+whatever key you pushed” and the same works for the Ctrl key). It will show you if that shortcut is already assigned to something else next to Currently assigned to:. Once you’ve chosen your shortcut, click Assign to begin recording your macro.

Figure 10

Now that you’ve clicked OK or Assign, you are in record mode, and it will continue to record until you click Stop Recording.

You can record anything with a macro. For today’s tip, we’re going to create a button to highlight overused words. So, using the Find feature, follow the steps to highlight any overused word(s) (Figure 11). See this post for more detailed instructions.

Figure 11
  1. Go to Find under the Home tab.
  2. Type in the word you want highlighted, check Find whole words only (Figure 11) and select Highlight All.
  3. Repeat steps 1 and 2 for any other words you overuse frequently.
  4. Click Cancel or the X to close the window.

At this point, all instances of overused words should be highlighted in your document. Now go back to the Developer tab and click Stop Recording (Figure 12). Note: It will continue to record until you click Stop Recording so it’s very important not to miss this step.

Figure 12

Quick review of the steps:
  1. Click Record Macro under the Developer tab.
  2. Select your preferred method to access the macro (button, keyboard shortcut, or list) and complete the steps to set up that method.
  3. Complete the steps for the function you would like to record—highlight words, format changes, font changes, etc. Anything that Word can do, you can record in a macro.
  4. Click Stop Recording.

    Now, if you chose the Button (Option 1) as you were setting it up, all you have to do to highlight all your frequently overused words in future documents is click on the button in your Quick Access menu (Figure 13). It might look different, depending on which icon you chose.

    Figure 13

    If you chose Keyboard (Option 2) as you were setting it up, then when you want to run the macro, just type in the keystrokes you selected. In this case, I chose Alt+Z.

    Now you’re ready to set up macros for anything you do frequently in Word.

    Anyone using this already? Anything you love to use it for?

    More Word tips posts here

    *Word 2007

    14 comments:

    1. Sounds awesome but a little scary to be honest. :) Thanks! I love these word tips.

      ReplyDelete
    2. Have not used this yet. I will check it out. Thanks.

      ReplyDelete
    3. Love your instructions with the visuals. We've got an instruction book for my office at work that has that.

      ReplyDelete
    4. LOL, and you thought my post yesterday was scary! ;)

      Thanks for putting in the pictures, I'd be completely lost without them.

      ReplyDelete
    5. Hi Abby, don't know if you're still reading this since this was 2 years ago, lol.

      I followed your instructions for making a macro for highlighting specific words. But for some reason, clicking on my macro button doesn't automatically highlight those words. In fact, it doesn't do anything at all!

      Do you know what I might be doing wrong? Thanks.

      Serena

      ReplyDelete
      Replies
      1. What version of Word are you using? I'm not sure why that would be an issue unless you're using a really old version, but thought I'd check, just in case. :)

        Other than that, the only thing I can think of is that you missed a step (or I missed a step). I'll run through it and see if it works by following the steps exactly. I'll get back to you when I'm done. I have to run out for a bit, so it might be a while but I won't forget you.

        And if you can give me any more info, that would be great. I understand that there's probably no more info to give, so if you can't, no big deal. We'll figure it out. :)

        Delete
      2. So, I tried it and it didn't work. I'm sure you're not surprised. I remember it working when I did the post but that was two years ago... ;)

        It might have something to do with an update, but it's probably just that my tutorial was wrong. I can't believe no one else said anything before this. Sorry if I caused you undo frustration.

        Okay. Now for how to do it the right way:

        Go to Replace instead of Find. Type the word you want to highlight in the "Find what:" box. Leave the "Replace with:" box empty. At the bottom, click Format and select Highlight.

        Make sure a highlight color is selected under the Home tab (if "no color" is selected it won't highlight anything). Then click Replace All.

        Repeat for all the words you want highlighted then close the box and click Stop Recording under the Developer tab.

        Now it should work. I tried it a few times to be sure. If you have any more problems, please let me know. And thanks for the heads up that it wasn't working. I'll be sure to update the tutorial.

        Have a great night! :)

        Delete
      3. I forgot to add, make sure your cursor is in the "Replace with:" box before selecting Highlight from the Format menu. :)

        Delete
      4. Thanks! (I'm using Windows Vista, Word 2007---the display looks like yours)

        Unfortunately, when I press the macro, it says something like: (approximate translation from Chinese)

        "Error in step 5941
        The member needed to group this/ congregate (?) doesn't exist."

        Hmmm...

        Let me try again.

        Delete
      5. Umm...it seems to work this time when I only tried it with one word...Lol, I'll try multiple words again and see what happens! (Sorry for the multiple posts...)

        Delete
      6. Oh it does seem to be working! I also accidentally made it record my opening another document (where I had all my keywords listed) and closing it, and reopening (maximizing) my original document, etc. I really have to remember to pause the recording while I do these things! ^^"

        Thank you so much for your help!

        Delete
    6. Oh, by the way, I heard we can copy and paste all of the sentences (that the highlighted words are in) onto another Word doc, as Jordan McCollum pointed out http://jordanmccollum.com/2012/07/mass-editing-word-macros/ (this is where I found the link to your page. :) )

      But is there a way to do this using the "record" function? (Instead of using the Visual Basic code?)

      Thanks again!

      ReplyDelete
    7. is there an easy way to highlight multiple words, but different words. A document that contains DVD, CD, Audio several times. Can these all be selected to be highlighted.
      thanks

      ReplyDelete