In the last tutorial you learned what macros are, and how they can save you lots of time by automating repetitive tasks. In this tutorial you'll learn how to create and play your first macro.
Steps to Create a New Macro
There are five steps to creating a new macro.
- Choose the Tools, Macro, Record command (or press Ctrl+F10) to begin the process. The Record Macro dialog box appears.
- Give the macro a name. (The resulting macro will be a file on your hard drive, so the name you give your macro will be the name of the file.)
- Choose OK (or press Enter). In a few moments, the status line reads Recording Macro.
- Create the actual macro by typing on the keyboard, or choosing commands. You can choose commands using the keyboard or the mouse.
- Choose the Tools, Macro, Record command (or press Ctrl+F10) to terminate macro recording.
Immediately after stopping the recording, a message will appear telling you the macro is compiling.
WordPerfect will execute your commands while defining the macro. This helps you better follow the course of the macro, but you may also inadvertently change your document in way you don't want.
You can create macros without disturbing current work by opening a new document (choose File, New).
After you complete the macro, close the temporary document without saving it by choosing Choose File, Close, then answering No.
Accessing Macros: Four Ways To Do It
WordPerfect macros can be created by recording your keystrokes and mouse movements, or they can be programmed from scratch. Either way, the result is a standard WordPerfect document. During playback, WordPerfect follows the instructions entered in the macro document as if they were map directions - turn here, do this, do that, stop when you see the first house on the left.
To provide as much flexibility as possible, WordPerfect provides four different ways to access the macros you create:
- By Ctrl+key (or if the Ctrl key combinations are all used up, also by Ctrl+Shift+key).
- By name
- By keyboard layout
- By Toobar
Let's quickly review the four ways of accessing WordPerfect macros.
Access by Ctrl+key
WordPerfect for Windows can store up to 36 Ctrl+key macro definitions - one for each letter of the alphabet, plus numbers 0 through 9.
They are termed Ctrl+key macros because of the way they are recalled: you press the Ctrl key and another key. See Macro Naming Conventions, below, for more information on the names to use in order to access a macro with a Ctrl key shortcut.
Access By Name
The Ctrl+key macros are the easiest to use because you can replay them by pressing just two keys. You will probably want to record the most common procedures as Ctrl+key macros.
But any serious WordPerfect user will quickly run out of Ctrl+key combinations, especially since . WordPerfect already uses many of the Ctrl+key (and a few Ctrl+Shift+key) combinations as shortcut keys for built-in commands.
As an alternative, you can save macros under names you provide. Once saved, you recall the macro by choosing the Tools, Macro, Play command. The Play Macro dialog box appears, where you can type the name into the Filename entry box.
Tip: You should get into the habit of playing macros by pressing the macro play keyboard shortcut: Alt+F10. Likewise, you should get into the habit of pressing Ctrl+F10 for recording a macro.
Access By Keyboard Layout
Macros that have been assigned a keyboard shortcut to a keyboard layout file are played back merely by pressing the appropriate key or keys. This technique is similar to Ctrl+key macros, but you have hundreds of keys to choose from, including the alphabet keys. The keyboard method is perhaps the easiest way to play back often-used macros when you have lots of different macros. It's especially handy if you don't use the mouse.
To learn more about assigning macros to a keyboard layout, in WordPerfect:
- Choose Tools, Settings, Customize, then click the Keyboards tab.
- Select any keyboard in the list, then click Edit.
- Click on Help and follow the steps.
Access By Toolbar
If you prefer to use the Toolbar, you can assign individual macros as buttons, and run the macros by merely clicking on the appropriate one.
To learn more about assigning macros to a toolbar, in WordPerfect:
- Choose Tools, Settings, Customize, then click the Toolbar tab.
- Select any toolbar in the list, then click Edit.
- Click on Help and follow the steps.
Hands On: Creating a Macro
Let's gain some practical experience creating macros in WordPerfect. Follow the short tutorial that appears below to create a macro that sets the margins to 2 inches for the left, right, top, and bottom of the page. Begin by starting WordPerfect in the usual manner if it isn't already loaded.
|Step||Action||What It Does|
|1||Ctrl+F10||Starts new macro.|
|2||2MARG Enter||Names macro 2MARG.WCM, and starts recording. (Note the WCM extension is assumed.)|
|3||Layout, Margins||Chooses Margins command from Layout menu.|
|4||2"||Sets 2-inch margins.|
|5||Ctrl+F10||Completes macro recording.|
Here's how this macro works.
Steps 1 and 2 start macro recording, using the name 2MARG.
- Steps 3 and 4 are the regular, familiar steps you take when setting margins.
- Step 5 completes the macro and saves it on the disk. The name of the macro file is 2MARG.WCM.
To play the macro,
- Choose Tools, Macro, Play (or press Alt+F10).
- At the Play Macro dialog box, type 2marg, and choose Play.
Canceling a Macro During Playback
You may cancel a macro that is playing back at any time by pressing the cancel key, Esc.
Sly WordPerfect macro writers know how to "cancel the cancel key," making it impossible to stop the macro by pressing Esc.
What these wily characters may not know is that you can still usually stop the macro by pressing Ctrl+Break.
Not all keyboards have a Break key, and on many that do, the Break key is labeled Pause on the top, and Break on the side.
Most macros are replayed very fast, even a series of even 100 keystrokes and commands may take only a moment to replay. You won't have to press the Esc key before the macro finishes. Rather, canceling a macro is handy when the macro has been slowed down or when you want to leave a macro that's gone haywire.
Canceling a Macro During Recording
Similarly, you may cancel a macro that you are defining by pressing Ctrl+F10 at any time.
This ends the macro but it also saves what you've done so far on the disk. If you don't want the macro, delete it from the disk or create a new macro using the same name (see the section below on "Working with Macro Files," for more information on deleting macros).
Macro Naming Conventions
The default file name extension for WordPerfect macros is .WCM. This file extension need not be used, but doing so makes playing macros easier. With the WCM extension you need only type the filename of the macro; you can leave off the extension as WordPerfect will assume it's WCM.
When recording macros, WordPerfect automatically appends the WCM extension, so you don't have to.
The other eight letters of the macro file name are fair game. The file naming conventions are the same as any other file you create on your computer. Specifically, macro names may contain from one to eight characters.
WordPerfect expects its Ctrl+key macros to be named in specific manner: Name the macro CTRLX.WCM, where x is a letter from A to Z. For example, the Ctrl+K macro is named CTRLK.WCM. (Similarly, Ctrl+Shift+key macros are named CTRLSFTX.WCM.
WordPerfect will ignore a Ctrl+ or Ctrl+Shift macro if there is already a keyboard shortcut with the same key sequence.
For example, the keys Ctrl+1 are already used for setting single line spacing. If you have a macro named Ctrl1.wcm WordPerfect will ignore it, and will just set line spacing.
If you want to use your Ctrl1.wcm macro you need to "unset" the key combination for single line spacing. You do this by choosing Tools, Settings, Customize, then clicking the Keyboards tab. Highlight the keyboard you're using, then click Edit.
Scroll down the list of key combinations until you see 1+Ctrl, then click the Remove Assignment button. Be sure to click OK to save your changes.
Finding Macros on Your Hard Disk
Macros can be on any disk and any directory. However, if the macro file is not in the directory or drive where WordPerfect expects it to be, the program won't be able to run it.
The most direct way to access a macro stored on a disk or directory other than the current one is to provide the drive and/or the directory explicitly at the Play Macro dialog box. However, this method also entails a lot of unnecessary keystrokes, so it isn't a method you'll want to adopt.
c:\macros\dblspace - Finds the macro DBLSPACE.WCM (for double space) in the macros directory on drive C:.
- g:\dblspace - Finds the macro DBLSPACE.WCM on drive G.
- \macros\format\dblspace - Finds the macro DBLSPACE.WCM on the current drive in the format subdirectory of the macros directory.
Using the Location of Files Feature
You may omit the drive and directory if you have previously told WordPerfect where to look for the macro files. The Location of Files box (Tools, Settings, Files, then Merge/Macro tab) enables you to identify a regular repository for your macros files.
You will want to take advantage of the Location of Files feature no matter how many macros you use. It will make storing and finding macros much easier if you keep them on a separate disk or in a separate subdirectory.
The standard location for your macro files is in the Default macro folder directory.
The Location of Files dialog box lets you also specify a supplementary directory for macros. Ordinarily, you'd specify a supplementary directory in a computer network. The supplementary directory lets you and others access the same macros. Your private collection of macros (the ones you only use) are placed in the default macro directory.
WordPerfect looks for macros in the following sequence:
- The default macros directory.
- The supplemental macros directory.
- Current document directory (this is the directory that is shown when you choose File, Open).
Working with Macro Files
Macros are actually standard WordPerfect documents, so you can erase, replace, and edit them just like any other.
If you were a WordPerfect for DOS user, this may be an alien concept to you, as the macros in that program were specially formatted files that you could not access except though a cumbersome "editing" screen. (The word "editing" is somewhat generous, as the only editing you could do in this screen was type and delete!)
To Delete a Macro File You No Longer Need
Macro files you no longer need should be deleted to reduce clutter and free up space on your hard drive. You'll probably find it easiest to use WordPerfect's Open File dialog box for this. The exact steps vary, depending on the version of WordPerfect you have. In general, follow these steps:
- Choose File, Open. Change to the directory that contains your macros.
- Select the file you want to delete.
- Press the Delete key.
- WordPerfect asks if you really want to delete the file. Choose Yes.
To Replace a Macro
You can replace a macro by simply recording over it. Press Ctrl+F10 and give the new macro the same name as the one you want to replace. WordPerfect asks if you want to Edit or Replace the original macro. Choose Replace.
To Copy a Macro
If you write or edit macros you'll find yourself making copies of old macros and reusing bits and pieces and others. Copying macros is easy, because all you need to do is copy the macro file. The exact steps vary, depending on the version of WordPerfect you have. In general, follow these steps:
- Choose File, Open. Change to the directory that contains your macros.
- Select the file you want to copy.
- Choose Edit, Copy.
- Change to the target directory, and choose File, Paste.
You can also copy a macro by opening it into WordPerfect in the usual manner, then choosing the Save As command and providing a new name. WordPerfect leaves the newly saved macro in the document window where you can start working with it immediately.
To Edit a Macro
Suppose you want to make a change to a macro, or include some extra steps in a macro you previously recorded. Assuming you know the special language WordPerfect macros use, you edit the macro simply by opening the macro file into WordPerfect:
- Choose File, Open.
- Type the name of the macro you want to open.
- Choose OK.
A typical recorded macro appears as a list of commands. Don't worry if it looks like Sanskrit. The macro language is really quite straightforward, and not difficult to master. However, it's beyond the scope of this short tutorial, so we'll have to leave the subject at that.
When you're done editing the macro, choose File, Save to save it. WordPerfect automatically re-compiles the macro whenever the file is saved.
Note: If you made any editing mistakes, and WordPerfect doesn't understand some macro command you tried to use, an error message will appear.
An alternative to opening a macro using the File, Open command is to use the Edit command in the Macros menu (choose Tools, Macro, Edit, and provide the name). The file is opened in the same way, with the following differences:
- You don't need to provide the directory in order to locate the file; WordPerfect automatically looks in the MACROS directory, as specified in Location of Files.
- WordPerfect automatically displays the Macro Feature Bar when it opens the macro file (this bar also appears when opening a macro with File, Edit, but only if the macro has been played at least once).
- Macros retrieved with the Edit command do not appear in the Last Opened files list at the bottom of the File menu.
To Print a Macro
You'll want to make paper copies of your macros so you can more easily review them. This is quite easy in WordPerfect because macros are ordinary WordPerfect documents. Assuming the macro is open in the current document window:
- Choose File, Print.
- Choose Print.
Use the options in the Print dialog box to print just selected pages, or to print a document that is not currently open.