WORDPERFECT MACRO TUTORIAL


1. Introduction

1.1 What is a macro?

You can think of a macro as a mini computer program within WordPerfect. A macro is a series of commands. The simplest macro consists of a sequence of WordPerfect commands; in other words, a macro that automatically performs WordPerfect operations that you could do manually. More complex macros include such programming concepts as variables, decisions, loops, and user interaction. Such macros use additional commands to implement these concepts.

1.2 Reasons for using macros

Macros are played with just a few keystrokes, so they can automate repetitive tasks and save a lot of time. Macros also guarantee consistency and accuracy; because they always play the same way, there is no chance of operator error (provided the macro was programmed correctly!).

1.3 Programming skills required for macros

Simple macros can be created just by storing keystrokes or (some) mouse clicks, so for those kinds of macros you do not need to know anything about programming. More complex macros that incorporate logic or operator interaction use programming techniques, but they are relatively simple to learn.

1.4 Difference between macros and styles

Styles consist of "stored" formatting and text; whatever is controlled by a style takes on that style's formatting. Like macros, styles guarantee consistency and accuracy, but by a different mechanism. One way to look at macros and styles is to consider macros as active and styles as passive: macros "do" and styles "are."

Macros insert and/or actively manipulate text and formatting codes in the document as if they were typed; the text and formatting performed by the macro in the document can be edited directly. Logic (decisions) and operator interaction can be incorporated into a macro. Once a macro is finished, its work is done.

Styles passively control formatting and text in a section of the document (or the entire document). A style contains formatting and text within the style itself, so a style can be edited only by using the styles editor. A style contains only formatting and/or text; it cannot incorporate logic (decisions) or operator interaction. When a style is changed, any and all text formatted with that style within the document immediately reflects those changes. So a style continues to control formatting and text as long as the style exists, just like any WordPerfect code.

1.5 Scope of this tutorial

This tutorial is aimed at beginning-level macro writers. No previous macro-writing or programming experience of any kind is assumed. The tutorial covers macro commands (product commands) and introduces basic programming commands (PerfectScript commands) for variables, user interaction, decisions, looping, branching, and error-handling. Not covered are user-created dialog boxes, custom message boxes, SendKeys, structured-programming concepts, nested commands, string handling and parsing, and other advanced topics.

This tutorial is based on the WordPerfect for Windows macro language, specifically WordPerfect version 8. Almost all of the concepts and commands in this tutorial are identical in versions 6, 7 and 2000 of WordPerfect for Windows. In WordPerfect for DOS 6.x many of the product commands are different; most of the programming commands covered in this tutorial are the same. Earlier versions of WordPerfect used a different macro language; this tutorial would not be useful for creating macros in those versions.

1.6 Resources for more information

Detailed information on all macro topics is available from WordPerfect's on-line help; unfortunately it is often buried several layers deep and can be confusing to find. The macro help files must be installed from the program CD in order for them to be available on the computer. In version 8, do Help/Help Contents, click on the Contents tab, then do Macros/Macro Programming/List of Commands.

Two WordPerfect macro gurus, Gordon McComb (www.gmccomb.com) and J.J. Westergren (www.wpmacros.com), have written comprehensive macro reference books, which are available from their websites. They are highly recommended.

An excellent source of information on macros and everything else related to WordPerfect are the various Corel newsgroups on cnet.corel.com.

Karen Gibson's site (w3.one.net/~kgibson/wpindex.htm), cutely mis-named "WordPerfect 8 Mis-Information," is anything but! This site is a treasure trove of information, help, how-to's, tips & tricks, and various life-savers in WordPerfect. Particularly invaluable is the FAQ (frequently asked questions) section: chances are a problem you might encounter is not unique, and others have found a way to deal with it. You will find those solutions in the FAQ.



© 1999 Seth H. Katz
All rights reserved


E-MAIL TO AUTHOR


BACK Table of
Contents NEXT