Difference between revisions of "Recording And Running Macros In Word 2003"
(Added tag: 'Word2003')
(Added tag: 'Helpdesk Documentation')
|Line 30:||Line 30:|
Revision as of 16:10, 6 January 2010
If you perform a repetitive task in Word, you can automate it using a macro. A macro is a series of Word commands and instructions grouped together as a single command. You can use the macro, which is, in effect a custom command, to perform the series of time-consuming, repetitive actions.
Some typical uses for macros are:
• To speed up routine editing and formatting.
• To combine multiple commands.
• To make an option in a dialog box more accessible.
• To automate a complex series of tasks.
To record a macro in Word, start the macro recorder and perform a sequence of actions. You can run the macro whenever you need to perform this sequence. For example, if you create mailing labels often, you can record a macro that accesses your mailing list and formats the information for printing.
When you're recording a macro, you can use the mouse to click commands and options, but the macro recorder doesn't record mouse movements in a document window. For example, you can't use the mouse to move the insertion point or to select, copy, or move items by clicking or dragging. You must use the keyboard to record these actions. When you're recording a macro, you can temporarily pause the recording and then resume recording where you stopped if you need to check a document.
Tips for recording a macro
• Before you record or write a macro, plan the steps and commands you want the macro to perform. If you make a mistake when you record the macro, corrections you make will also be recorded. You can edit the macro later and remove unnecessary steps you recorded.
• Try to anticipate any messages that Word might display. For example, if your macro includes a command to close a document, Word asks you to save the document if it contains unsaved changes. To avoid this message, record saving the document before closing it.
• If the macro includes the Edit menu command Find or Replace, click More in the Find tab, and then click All in the Search drop-down list. If the macro searches up or down only, Word stops the macro when it reaches the beginning or end of the document and displays a message asking whether you want to continue searching.
• If you want to use the macro you're recording in other documents, make sure that the macro doesn't depend on the current document's contents.
• If you use a particular macro often, assign it to a toolbar button, a menu, or shortcut keys. That way, you can run the macro directly without having to open the Macros dialog box.
Recording a Macro
1. Open a document.
• If you plan to use the macro with a template, open a document based on the template.
• If you plan to make the macro global, open any document.
2. From the Tools menu, point to Macro, and then click Record New Macro on the submenu; the Record Macro dialog box opens.
3. Type a name for the macro in the Macro name field.
4. Select a template in which to store your macro from the Store macro in from the drop-down list.
5. Enter a description in the Description field to help you remember what the macro does.
6. To create a shortcut to the macro, use one of the following two methods:
• Method 1: Click (Toolbars) to add the macro to a toolbar; the Customize dialog box opens.
a. Click the Commands tab.
b. Your macro, in the format , will be listed in the Commands field. Click and drag the macro onto the toolbar of your choice. There will be two visual clues to help you determine when the macro button is in a desirable position on the toolbar:
- While dragging your macro, a box appears below and to the right of your cursor. Inside the box an X indicates you are not in position to drop the macro; a + indicates you are over a toolbar and may drop the macro.
- An I-beam (I) indicates the spot where the macro button will appear on the toolbar when dropped.
c. From the Modify Selection pop-up menu, select Default Style; the button for the macro will change from to .
d. Click again on the Modify Selection drop-down list, point to Change Button Image, and then select an image for the macro button from the submenu.
e. Click Close and go to step 7.
• Method 2: Click (Keyboard) to enable a keyboard sequence to invoke the macro; the Customize Keyboard window opens.
a. Press a new shortcut key sequence, such as Alt + Ctrl + A or
Ctrl + 8. The key sequence appears in the Press new shortcut key field and the text Currently assigned to is displayed. If there is a command already assigned to that key sequence the command is displayed. An unassigned key sequence is indicated by the text [unassigned]. See the examples below:
b. Click Assign when you find an unassigned key sequence.
c. Click Close and go to step 8.
7. Click OK.
8. Word will begin to record your actions and the Macro Recording toolbar with a stop and pause button will overlay your open document.
• Press to stop recording.
• Press to pause the recording process so you can check commands or the document.
• Press to resume macro recording.
9. Complete the process you want to record.
Note: If you make a mistake, choose the Undo command on the Edit menu (or press
Ctrl + Z . If you are in a dialog box click Cancel to prevent the dialog box from being recorded.
10. Press to stop the recording. The macro is now available for use.
Note: You can open a recorded macro in Visual Basic Editor to modify the instructions. You can also use Visual Basic Editor to create very flexible, powerful macros that include Visual Basic instructions that you cannot record.
Running a Macro
1. Activate the document on which the macro is designed to work.
2. Use your preferred method of accessing the macro and running it:
• Using the Tools menu.
a. On the Tools menu, point to Macro, and then click Macros on the submenu.
b. In the Macro name field, click the name of the macro you want to run.
c. If the macro doesn't appear in the list, select a different list of macros in the Macros in field.
d. Click Run.
• Using a Toolbar button, if you created one.
a. Click the button on the Toolbar.
• Using a keyboard shortcut, if you created one.
a. Press the key sequence assigned to the macro.
You can store macros in templates or in documents. By default, Word stores macros in the Normal template so that they're available for use with every Word document. However, if a macro is useful only for a particular type of document, you may want to copy the macro to the template attached to that document and then delete the macro from the Normal template.
To copy, delete, or rename a macro, use the Organizer.
1. On the Tools menu, point to Macro, and then click Macros on the submenu. The Macros dialog box opens.
2. Click Organizer. The Organizer dialog box opens.
3. Use the buttons to copy, delete, or rename macros.
4. When you’re finished, click Close.