WORDPERFECT MACRO TUTORIAL


2. Creating Macros

2.1 Creating a macro

Macros can be created in two ways: by recording keystrokes and/or (some) mouse clicks ("recording"), or by typing the macro commands, using the macro programming language ("programming"). Only text input or WordPerfect codes done by keystroke or mouse click can be recorded. Decision processing, variables, loops and other features of the programming language must be typed into the macro itself. (Inserting programming commands is discussed later in the tutorial, in the section on editing macros.)

To begin recording a macro, click on Tools/Macro/Record, or press Ctrl-F10. You will be asked for the name of the macro. Macros are files like other WordPerfect documents, but they have "wcm" as the extension in the file name. You can name a macro with any name that would be permissible for a file. You should use a name that describes what the macro does, and will be easy to remember. WordPerfect will automatically append the ".wcm" extension to the filename.

2.2 Macro recording

WordPerfect indicates that you are recording a macro by showing the phrase "Macro Record" on the status bar. From this point WordPerfect stores the actions you take in the program in the macro; that is what is meant by "recording." Once you start recording, the results of your keystrokes and/or mouse clicks will be stored in the macro, until you end the recording by clicking on Tools/Macro/Record and uncheck Record on the menu, or by pressing Ctrl-F10 again.

Note that what will be recorded is the effect of your keystrokes or mouse clicks, not the keystrokes or mouse clicks themselves. (This is a change from WordPerfect's macro language before version 6). For example, if you record the sequence Format/Line/Spacing/2/OK, what will be recorded in the macro is that you changed to double-space line format. Similarly, if you type "xxyyzz" and then backspace twice to delete "zz," what will be recorded is that you effectively typed "xxyy." If you begin an action and then abandon it or reverse it, there is no "result," so nothing is recorded in the macro.

2.3 Recording mouse clicks

While recording a macro, you will notice that the mouse cursor changes to a circle with a slash through it when you move the mouse over the document. That is because mouse clicks within the document (to position the cursor, or to select text) are not recordable. For these operations you must use keystrokes. You can use the mouse to choose items from a menu or in a dialog box; the results of these mouse clicks will be recorded.

2.4 Text macros

The simplest macro is one that just inserts text into a document, as if you had typed the text. When you create a text macro, keep in mind how it will be used. If the macro is a phrase, you may want to include a space at the end. If the macro is a full sentence, you will probably want to include the period and the space(s) after the period. If the macro is a separate paragraph, you may want to start with a tab, and will probably want to end with one, and maybe two hard returns. Thinking ahead regarding how the macro will be used will make your macros more useful and convenient.

2.5 Cursor position

Keep in mind the position of your cursor when you record a macro. If your macro requires that the cursor be in a particular location in the document, the macro should first position the cursor at that location before it does anything else. If you neglect to do this, you will get unpredictable (and often undesirable) results when the macro is played, since the cursor may not be in the necessary location at that time.

2.6 Where macros are stored

Macros are stored in the directory or folder designated as the macro directory in the WordPerfect program configuration. Look under file settings (Tools/Settings/Files) to determine or change where WordPerfect will look for macros when they are invoked, and where it will store macros when they are recorded. Later versions of WordPerfect allow both a "default" directory (where WordPerfect will look first) and a "supplemental" directory (where WordPerfect will look if the macro is not found in the default directory). WordPerfect comes with a number of macros included; it is often a good idea to keep those macros in a separate directory from those you program yourself.

Macros can also be stored in templates. Template macros are beyond the scope of this tutorial.




© 1999 Seth H. Katz
All rights reserved


E-MAIL TO AUTHOR


BACK Table of
Contents NEXT