Join Gini von Courter for an in-depth discussion in this video Record a simple macro, part of Word: Automating Your Work with Macros.
- [Instructor] With our macro creation environment set up let's take this for a spin. This document is called Unformatted Report and it's available in the exercise files that you can download on the same page as this course in the training library or any other document that you would like to work with. What I'd like to do is add a title to this document and I'm actually starting with the insertion point right there. That's where it was when the document was opened. After I've inserted a title I also then want to insert today's date.
I want to make sure that I modify all of the text by applying our styles to this document. Let's begin by firing up the macro recorder. Three different ways I can do this. I can go to the developer tab and choose Record Macro. I can go to the review tab and choose Macros, Record Macro. Both of those choices give me Pause button as well if I would like. The third option, the one I use the most is to click the Macro Record button here on the status bar.
I'm going to click and I need to give this a name. I'm going to call this Format Report. Don't immediately click Assign Macro to the button or keyboard because when you do you don't get to make another choice in this dialog box. I want to store the macro so it is available to any documents that I create because this is a set of formatting that I do frequently. So, I'm going to store this in Normal.dotm. This is to apply body style and add title and creation date at the top.
If I want to put in a keyboard shortcut for this, I'd click this button, or I can say I'd like to assign a button to this macro. We're going to try for a keyboard shortcut. This is format report. What I can do is choose a set of keystrokes and they'll either be unassigned or perhaps it's something that I'm willing to give up. For example, if I do Control Shift F, for format report, that's currently associated with font, if I want to open the font dialog.
I don't want to give that one away. Perhaps Alt Shift F, insert merge field. Nope, I use that one too. Control Alt Shift F, unassigned. If I can remember that's my keyboard shortcut, I'm going to hold down Alt Control Shift and F to fire up this report format. That works well for me. I can click Assign. There we go and now I'm going to click Close, and when I do the macro recorder has started. The clue for that is if I look at my pointer there's a little icon, and that's not Bad Robot's head.
That is actually a picture of a cassette recorder because when we started recording macros that's what recording media looked like. I'm going to begin by selecting all of our text. While I'm recording the macro, I can use my mouse to choose commands, but I can't use it to select text. I have to use keyboard shortcuts. If you record a lot of macros you will know all the keyboard shortcuts, but if not this is a good time to refer back to the shortcut document that we created earlier.
I'm going to hold Control and hit A to select all my text. I'm going to return to the home tab, and I'm going to assign Normal. That looks good. I need to get back to the start of my document. So, that's Control and Home. I'm going to press Enter and then hit the up arrow to go back up and I'm going to enter my title for this, which his this a video report. I want to select all the text on this line. One way I could do that would be with the mouse but that's not what's available to me.
Another key you're going to use a lot is the F8 key. That's called extend select. If I hit the F8 key and then I hit Home I've now selected that entire line. I can assign, for example, the title style to that line. To get out of extend select you hit the Escape key. Now, if I hit the down key, I'm in the line below. Hit Home to go back to the start. Press Enter again, go back up again, and I would like to now insert the date that this document was created on.
Let's go to Insert, Quick Parts, Field, and here are all the fields that are available to me and if I wanted things like date and time then here's the create date for this document. Here's the date that this document was last printed, and here's the date it was last saved, which would also be a modification date. My choice here is do I want the date it was built originally or do I want the date that it was last saved? After you've chosen whether you'd like to have the create date, print date, or saved date you can choose whatever format you'd like.
Click OK to insert that field code. This is what I'd like my finished document to look like. I might like to be at the start of the document again in terms of the position of my insertion point, so I'm going to hit Control Home Home to go back to the start of my document. I'm now going to stop recording. Now, if I had wanted to pause recording between when I started and now, remember that either the view tab or the developer tab have a pause button and then I can restart again, but I'm going to stop either by clicking here or by clicking the stop button on my status bar.
Having done that I have now finished recording my macro. I'm going to close this document. I'm asked do I want to save changes to it. No, not really. There are my keyboard shortcuts. I'm going to end this Word session because if I do I may be prompted to save changes to Normal.dotm and I should say yes to that if I am so prompted.
- List the steps required to run the macros on a document you created when you open the document and see a SECURITY WARNING banner message.
- Explain how to run a macro.
- Identify where to save a building block if there is no logical gallery for it.
- Recall the best way to create an auto macro.
- Recognize why you would create a macro in the Visual Basic Editor rather than using the Macro Recorder.
- Identify what you can add any existing macro to.