Tutorial 1: Recording a macro in Microsoft Word

This tutorial covers the steps to record, stop, pause and resume a simple macro in Microsoft Word, followed by some simple practice exercises.

A note on screen shots The screen shots that appear in the tutorials may look slightly different from what you see on your own screen because you have a different version of the software. In most cases, these differences are only cosmetic. The functions will usually be found in a similar place. If not, we will usually warn you.

In your IT career, you’ll need to cope with such differences in versions of software. If you can’t find a particular function or feature where you expect it to be, you should go straight to the help for the software you are using.

Step 1: Turn on the recorder Double-click REC on the status bar, as seen near the mouse pointer in the figure below, to open the Record Macro dialog box.

REC on the status bar

Do not be fooled because the button appears to be greyed-out. You can also click Macro on the Tools menu and then click on Record New Macro. Either way will bring up the Record Macro dialog box below.

1 2005

Record Macro dialog box

Step 2 Enter information into the Record Macro dialog box In the Record Macro – Macro name field, type a name for the macro. This name must begin with a letter and contain only letters and numbers. Use meaningful names for macros. This is important because you may finish up with many macros and you need to recognise them quickly. It is also advisable to add a description.

Where to store the macro You may store the macro in the normal template making the macro available to all Word documents on that computer. Or, you may store the macro in the open document. This makes the macro available only if this document is open. If you create a template from this document, then the macro will be available in any document created with this template. If you want to transport the macro to another computer and you have saved the macro in the normal template (to make it available to all documents), then you will have to copy the macro into another template. It is not wise to copy the normal.dot template from one machine to another because you will destroy all custom settings on that machine.

Describe the template

To include a brief description of what the macro does, type text in the Description field.

2 2005

If you assign the macro to a menu item or a toolbar button, this description appears in the status bar when you point to the menu item or the toolbar button. A description can contain as many as 255 characters, but only about 100 characters will fit on the status bar.

Assign the template

To assign the macro to a toolbar button, a menu item, or shortcut key, click the appropriate button. When you finish assigning the macro, click Close in the Customize dialog box to begin recording it.

Caution!

Do not close the Stop Recording toolbar. If you do the macro may keep recording without you realising it.

Stop recording toolbar

There are two buttons on the Stop Recording toolbar. (See figure below.) The square button is used to stop the recording and complete the macro. The other double-bar and circle button is used to pause and resume the recording.

Stop Recording toolbar and recording mouse pointer

Step 3 Perform the actions you want to include in your macro The macro recorder cannot record mouse actions in document text. You must use the keyboard when recording such actions, as moving the insertion point and selecting text. However, you can use the mouse to click commands and options when you are recording a macro.

Step 4 Stop recording To stop recording your macro, click on the square stop button on the Stop Recording toolbar shown in the figure above.

3 2005

Suspending and resuming recording The Stop recording toolbar has two buttons. The first one is stop, the second is pause. Use the Pause button to suspend recording.

Perform the actions you do not want to record.

To resume recording, click the same button once again.

4 2005

Practice activity 1

Now practise creating a simple word processing macro.

While formatting a document, a common activity is to make a word bold. Let’s make a simple macro that will make the current word bold. Try the actions out using only the keyboard first. Then do the recording. You can always delete a bad macro and try again.

 Open a new document and type a few sentences

 Position your cursor in the middle of a word to be made bold

 Start recording the macro. (Menu Tools/Macro/Record New Macro)

 Type in a new name for the macro in the Macro name input box. Use the name MakeBold so you can refer to this macro and make changes to it later if required.

 Click on the Assign macro to Keyboard button

 The cursor is flashing in the Press new shortcut key so press Alt-B. (Hold down the Alt key and tap the letter B) The input box now shows Alt+B as the shortcut key.

 Click on the Assign button. Then click on the Close button. Now you are in Recording mode. You will see the Stop Recording toolbar and have the recording mouse cursor. The above steps are similar for all macro recording.

 Press Ctrl-Left Arrow (Hold down the control key and tap the Left Arrow) This moves to the beginning of the word. You have to do it this way since the macro recorder does not record mouse selections and the words you use it with may be of different lengths.

 Hold down the Shift key and while holding it down press Ctrl- Right Arrow (Hold down the control key and tap the Right Arrow) This moves to the end of the end of the word and has selected the word.

 Click on the Format menu

 Choose the Font item

5 2005

 Choose the Font tab

 Select Bold from the Style list

 Click on the OK button. The Font dialog box closes and the word is now bold and still selected.

 Press the Right Arrow key twice to remove the selection and to have the cursor in the next word. This gives you the capability to bold word after word by pressing Alt-B repeatedly.

 Press the square Stop button on the Stop Recording toolbar.

 Try the macro out on other words in the text you typed in by locating the cursor and pressing Alt-B.

Things to remember…

Recording a macro can be a tedious task requiring planning and knowledge of how the application works as well as the recording capabilities. When you compare the few minutes it took you to record and test the macro to the cumulative amount of time your client spends doing the same repetitive tasks, then you can understand the time advantages.

A client may ask for your help in producing a macro that you consider not important. The client is the best judge of the importance since it is their work that will be affected. Remember your clients are doing different tasks from you so require different tools and solutions and have different skills. It is up to you to supply the tools and solutions in a useable form.

6 2005

Practice activity 2

Record a new macro that will display:  your full name

 font size 14

 Arial font

 bold

 italic

 6pt before paragraph spacing. Save the macro as MyName and run to test it. When your new macro works satisfactorily:  Assign the macro to shortcut keys (Try Alt-N).

 Create your own toolbar and assign the macro to it.

 Add the macro to the Tools menu as the last menu selection and name the selection my_name.

Hints Remember to use the keyboard for all text selection and to make it easier to use elsewhere you should select whole words (Crtl-Arrow) not a fixed number of characters. Someone else may want to do the same thing and not have to redo the whole macro. Most of the requirements in the macro are available from the Format/Font dialog in a similar manner to the way you made the MakeBold macro earlier. You may be working in an environment in which the Normal Template may be rewritten from the server during the start up process. This means that any macros saved in the normal template will be deleted. This might be the case if you are studying this subject using a classroom computer. The solution is to save the macro in a different file.

7 2005