Macro Overview
Macros let you group a series of commands and instructions which, when run, carry out specific tasks automatically.
Now that the newsletter is going to be a monthly affair, Nick wants to group a series of commands and instructions which, when run, carry out specific tasks automatically. These include routine editing and formatting,that combine multiple commands and automate a complex series of tasks.
Nick uses the Macro Recorder to record the actions which can then be repeated over and over again simply by using the macro.
1. To assign a Macros to a toolbar button, menu item or shortcut key.
Press <Alt F8> (or use Macros in the Tools menu).
Select the required macro from the list and run it.
2. Nick wants to create a relatively simple macro which automatically types some text (e.g. Newsletter, Issue No. and Volume No.) in bold letters and centers it.
Create a new document.
Open the Tools menu, select Macro then Record New Macro.
Enter a name for the macro and Assign it to a keyboard or a toolbar or click close if you do not want to assign it.
If you assign it to a keyboard.
- In the Press new shortcutkey box, enter the keystrokes required, e.g. <Alt b> .
- Change Save changes in to the current document (Document1).
- Check this isn't already assigned under Currently assigned to then click on [Assign] .
-
Finally, press <Esc> to [Close] the Customize Keyboardwindow.
The Stop Recording Macro toolbar will appear - DO NOT CLOSE IT
Carry out the sequence of actions you want to record:
- Click on [Bold] to turn on bold text
- Click on the [Center] button to center the text
- Now type in your text (eg your name or department.
- Click on [Bold] again to turn off bold text
- Press <Enter> then click on [Align Left] to return to normal typing
Click on [Stop Recording],the left hand button on the toolbar, to finish recording your macro.
3. Nick wants to try out the newly created macro as follows:
Press <Ctrl a> to select your current text and <Delete> it.
Now press <Alt b>, e.g., Newsletter, Issue No. and Volume No. should appear centered and in bold letters.
OR
Open the Tools menu, choose Macro then Macros... (or press <Alt F8>)
Make sure All active templates and documents is selected in the Macros in box
In theMacro name box, select the macro you want to run - BoldName
Press <Enter> or click on [Run]. Your name should appear in a second.
4. Nick wants to make certain changes to the macro.
Click on Tools menu, on Macro, and then click on Macros....
Click the name of the macro you want to edit (Bold Name) in the Macro namebox.
Click on [Edit]
The Editorwindow now appears.
Find the line which types out the text and edit it in some way. (e.g., add your middle name) .
In the line above which ends in ParagraphCenter, change Center toRight.
Click on the [Close] button (or press <Alt q>) to close the editor and return to your document. Note that changes are saved automatically.
End by testing out your macro. Press <Alt b>. You should find that your new text is displayed, this time aligned on the right.
Though the macro appears to work perfectly, it could in fact be improved. You may have noticed the lines which read Bold = wdToggle. By clicking on the [Bold] button, bold wasn't turned on, it was toggled. If you switch bold on before you run the macro, then your text doesn't appear in bold and at the end of the macro, you are not returned to plain letters. Try it.
Type in some text to check that it appears as normal then press <Enter> for a new line.
Turn on [Bold]then press <Alt b> to run the macro and note what happens.
Type in some more text. These will appear in bold! Then press <Enter> for a new line.
To overcome this problem, you would need to establish normal text at the very start of your macro. You could have done this when recording the macro (use the Format menu, Font command and select a Font Style of Regular). Try this, if you like, or edit the first line of the macro as follows:
Press <Alt F11> to switch into the Editor .
Change Selection.Font.Bold = wdToggle to Selection.Font.Bold = True .
Close the Editor then run your macro again. This should work whether or not bold is already on
5. Nick is worried. Someone told him that macros have been used to spread viruses between computers. He wants to be sure of the security of his computer.
Open the Tools menu, choose Macros then Security. The following screen appears:
Set this to Medium then click OK.
When you next open a file containing a macro, a dialog box similar to the one below appears
Choose [Enable Macros] to activate the macros or [Disable Macros] if you don't trust the source.
Note: If you set security to Low, then no macro checking is performed. If security is set to low and if the anti-virus software on your computer is not kept up-to-date, then you are asking for trouble if you pick this option.
To Delete a Macro
Open the Tools menu, choose Macro, then Macros.
Inthe Macro name box, click on the name of the macro you want to delete
Click on [Delete] and confirm the deletion by clicking on [Yes] (or press <Enter>)
Press <Esc> or click on [Close] to close the Macros dialog box