Electronic Edition

Gordon McComb

WordPerfect 5.1 Macros and Templates

Copyright 1990, 1997 by Gordon McComb.
All Rights Reserved


Mark Twain is thought to have been the first professional writer to use a typewriter. As with all writers since, the typewriter -- operated by a series of mechanical levers, cranks, and pinions -- made Twain a faster worker. He may even have been a better writer because of the typewriter. The keyboard allowed him to commit his words to paper at a rate more compatible with his flow of thought.

Considering Mark Twain's contribution to American literature, you can only wonder what he would have written had he owned a personal computer and a word processor. Twain would never have been able to outpace the computerized word processor. Jammed keys are an impossibility. He could write as fast as he wanted.

His editors were sure to have appreciated it, too. Revisions would be a snap; there's no need to retype entire pages with a word processor. The appearance of manuscripts would have been improved by using common word processor features such as automatic underlining, centering, and changeable character pitch. And with a high quality output device, like a laser printer, Twain's words could be automatically converted to book form, avoiding time consuming and expensive typesetting.

Twain didn't have the luxury of the modern computer and word processor, but these tools are readily available to us today. Only short-sightedness or a fear of technology keeps them from being used. Whether you are in the business of writing best selling novels, company reports, correspondence for the boss, or letters for the charity ball, a word processor helps you do your work faster and more professionally.

But like sexy sports cars, once you get a taste of the efficiency of word processors, you find yourself transformed into a speed demon. You look for small, hidden tricks and techniques that help you become even more proficient. You start gauging your success not by the number of hours it takes to complete a task, but by the minutes -- even seconds. You become impatient as the computer whirs, clicks, and processes your words, digesting tens of thousands of bits of information in the wink of an eye. But it's not fast enough for you. You are possessed by the computer word processor speedbug.

Fortunately, there's a cure. If you use WordPerfect on your IBM PC or clone, you can speed up the process of writing, editing, and printing documents by at least another 50 percent, often much more. How? By using macros and templates.



In WordPerfect, macros are keyboard shortcuts to entering a long string of commands or typing lengthy passages of text. Once a macro is defined, it is recalled at any time by pressing a few keys. Any operation in WordPerfect can be assigned a macro -- writing, editing, drawing, formatting, spell checking, you name it.

You can dramatically increase productivity and efficiency when working with WordPerfect by creating sets of macros for common tasks. For example, you can use macros to:

If you've used the macros features in the earlier 4.2 version of WordPerfect, you know how they increased your productivity. The macros feature in WordPerfect 5.1 provides the same functionality, yet is far more advanced, offering a sophisticated programming language that makes your job behind the word processor even easier.

Templates are not a feature of WordPerfect but an application you devise. Strictly speaking, a template is a "bare-bones" document -- usually a merge file -- that you store on the disk for future use. Templates can be used with macros or styles, and are an intended to automate the tasks you perform frequently, freeing you from much of the grunt work that presents itself each day.

For example, if you often prepare invoices for products or services, but don't have a stand-alone accounting program for such a purpose, it's a fairly easy matter to construct a ready-made template that you can use to swiftly produce and print the invoice.

All of the functional macros and templates found in this book are included in the Applications Disk, packaged with this book. Appendix A explains how to access the files and use them with your copy of WordPerfect. Please note that WordPerfect 5.1 files -- especially macros and merge documents -- are not compatible with earlier versions of the program. The files on the Applications Disk are designed only for WordPerfect version 5.1 or later (some macros can be used with version 5.0).



This is not a beginner's book on WordPerfect. It does not teach the fundamentals of WordPerfect and how to use its features, nor does it review these features.

You are expected to already have a good working knowledge of WordPerfect before you read this book. You need not be a pro, but at the very least you should know how to write and edit text, how to format text using codes, and how to print your documents. Knowledge of the program's advanced features, such as the spelling checker, thesaurus, and automatic line numbering, is also valuable.

New to WordPerfect? Then you are urged to read the manual that accompanies the program. A number of good books, available at book stores and libraries, offer excellent ancillary training on using WordPerfect. If you are acquainted with WordPerfect, but are not an expert user, you'll want to keep a copy of the manual beside you as read through this book. If you come across a technique or concept that is unfamiliar to you, pause to read about it in the manual before proceeding.

As of this writing, the latest release of WordPerfect is version 5.1. This book detail the creation of macros as they apply to this version, but many of the techniques will also work,, with some modification, when using Version 4.2 and 5.0. Chapter 21 describes the differences between the macro language fount in versions 5.0 and 5.1, and how to write macros that can be used with both.



This book is divided into three parts:



The following conventions are used in this book:


Key Notation in Text Press these keys
Test [Enter] "T," "e," "s," "t," and "Enter."
[Ctrl]-F "Alt" and "F" keys simultaneously.
[Ctrl]-[F10] "Ctrl" and "F10" function key simultaneously.
Key Meaning
[Esc] Escape
[Tab] Tab express
[Ctrl] Control
[Alt] Alt(ernate)
[Shift] Key shift
[Spacebar] Spacing bar at bottom of keyboard (usually unmarked)
[Backspace] Backspace key usually key on top row, next to "+/=" key.
[Enter] Enter (or Return) key in main part of keyboard. You may also use the [Enter] key on the numeric keypad.
[Insert] Insert or "Ins" key in keypad or cursor pad.
[Delete] Delete or "Del" key in keypad or cursor pad.
[Home] Home key in keypad or cursor pad.
[Page Up] Page Up key in keypad or cursor pad.
[Page Down] Page Down key in keypad or cursor pad.
[End] End key in keypad or cursor pad.
[PrtSc*] Print screen key, found in various locations on different keyboards; used with the Shift key to make a printed copy of the screen display.
[F1] thru [F10] Function keys labeled F1 through F10. Function keys F11 and F12 (some keyboard models) are not required by WordPerfect 5.1 and may not be accessible with certain PC-compatible computers. With the key remapping feature of WordPerfect 5.1, you may use the extra function keys if your computer can access them, but for the purposes of this book, we shall ignore them.


Entry Notation in Text Press these keys
{filename} Enter your own filename, such as "TEST.DOC" or "MYFIL.TXT."
{field entry} The entry of a text field for a merge print document, such as a person's name, address, or account balance.


Key Sequence What it Does
1. [Ctrl]-[F10] Starts new macro definition.
2. {macro name}
Names the macro.
3. [F7] N Y Exits WordPerfect without saving the document.

You program macros from within a special editing box, accessible through the Macro Define, [Ctrl]-[F10], key. You may edit an already created macro or define one from scratch. To edit or define a macro, press the same keys on the keyboard that you normally would to invoke some action in WordPerfect. For example, to clear the current document screen but not exit out of WordPerfect, you'd type:




This book indicates the exact keys to press by showing you a printout of the macro definition,, such as:





Most of the keys in the macro editing screen are self explanatory. A more thorough discussion of macro keys can be found in Chapter 3, "Editing Macros."


1.  {PROMPT}Press any key to continue.~ 
2.  {ASSIGN}1~~ 
3.  {IF EXISTS}1~Thank you, please wait.~ 
    {END IF} 


This is the part where the author expresses his deepest gratitude for those people who helped make this book a reality. This is my book and I did almost all of the hard work myself, but there are a few people who made my job a little easier.

Many thanks to WordPerfect Corporation for letting me take a look at version 5.1 while it was still in the developmental stage. I also value the time lent to me by Kevin Merrell of WordPerfect Corp's PC Testing, and the talent of programmer Layne Cannon for his fantastic job at creating WordPerfect's 5.1's advanced macros. Kudos go to Marketing Graphics Incorporated for their fine desktop publishing artwork, some of which I used in this book with their permission.

Many folks on CompuServe's WordPerfect Support Group forum gave freely of their time, suggestions, and (gasp!) criticisms on the first edition of this book. Space (and time) does not allow me to thank each one individually, but my gratitude is there nevertheless.

Though its considered bad form to thank your editor, I'll do it anyway. Michael Roney at Bantam Computer Books made the original project for this book fun, and his progressive editorial policy allowed me the creative freedom to write this book the way I envisioned it. That's a rarity in today's computer book publishing industry.

As always, my wife Jennifer and children Mercedes and Marshall saw to it, between those long hours crouched behind my computer, that I remembered I was still part of the human race.


 Top Contents

WordPerfect 5.1 Macros and Templates
Electronic Edition
Copyright 1990, 1997, Gordon McComb.  All Rights Reserved.
First published by Bantam Electronic Publishing, 1990.