Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate

Barry MacDonnell's
Toolbox for WordPerfect

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2024 by Barry MacDonnell. All Rights Reserved.

Page updated Sep 10, 2023

WordPerfect Tips
Main tips page | Browse more tips

Important

The macros you find here on the Toolbox for WordPerfect site and that are inside downloadable .ZIP files are already compiled and functioning (see Downloading and Installing Macros and Templates).

Such macros included in .zip files will have .wcm filename extensions. They are not the "raw" or "plain text" macro code such as you might see posted on another web site (and even on some Toolbox pages).

On the other hand, plain-text macro code — the subject of the next column — is simply a series of macro commands that were typed or copied into the site as ordinary text characters. Those commands are not yet macros!

The simple, step-by-step procedure in the next column turns such plain-text macro code into a functioning macro.


Note

If you use the first release of WordPerfect 11 (i.e., version 11.0.0.233, as shown in your WordPerfect's Help > About WordPerfect menu), then you should read this page (in the WordPerfect 11 section) about a bug in that release that can impact macros from any source, even those from Corel that were shipped as part of the program.


How to copy plain-text macro code from the Internet
(i.e., a web page, newsgroup post, or email) into
WordPerfect to create a functioning macro.



TL;DR? This page is very detailed because I cannot know how much you know about this method. But it is not a very complicated process. Once you have used the following steps once or twice you will find them to be a quick, simple, and easy way to use macros that others have created and publicly posted in "raw" (plain text, uncompiled) form.

To begin, note the frequent use of the word "copy" on this page. You should not have to manually type any text to create the functioning macro. You can do so later if you want to edit it, but for now you can simply use standard Windows copy and paste methods, as explained below.

As we all know, typing can be prone to error, and macro commands are very exact. A macro follows a set of instructions (the "macro code"), but since it is a dumb robot even a single misplaced character or punctuation mark can prevent it from working properly. [Always play new macros on a copy of your document until you are confident they suit your needs.]

Hence, the process below is basically a simple copy-and-paste-without-any-fancy-formatting procedure from the source material into WordPerfect, which should help ensure accuracy.

Step 1 (of 7)

Briefly examine the plain-text macro code to determine exactly where it begins and ends.

This is a simple step, but sometimes overlooked.

Often, macro writers will use programmer's comments to tell you where the macro begins and ends, or explain a macro's purpose, or give you the reason for particular commands.

In WordPerfect, such comments typically begin with two slash marks (//...comments...). Sometimes they are surrounded with slash-and-asterisks (/*...comments...*/). [See here for other types.]

They tell WordPerfect's macro compiler to ignore what follows (or is enclosed by) them.

Very often the first operational command in the macro is an Application() command. (Don't worry if you don't see an Application command: It is not always used in posted code.)

The last operational command is usually either Return or Quit. For most standalone macros these are equivalent commands, but Quit is more aggressive: It immediately terminates the macro stream of commands.

Also, you can generally ignore any lines at the beginning and end that contain only horizontal lines, spaces, or similar "separators." These are typically used to improve readability but can be used to delimit macro commands, which is sometimes necessary.
Note

On WordPerfect Universe, the posted plain-text code is usually (but not always) inserted inside a scrollable Code: window, located inside the body of the post.

The code in that window can be selected (following the instructions in
Step 2 below) and copied the same as code in any other part of a post.

* * *

IMPORTANT UPDATE (March 2022) relating to
plain-text code copied from WordPerfect Universe

WordPerfect Universe's hosting site had to move to new servers in February 2022, which required updating the software that makes the WordPerfect Universe site work.

Unfortunately, the updated software can now affect certain material inside any post that uses the aforementioned Code: window — including any special formatting the writer might have added to some material such as bold, italics, underlining, color, or font changes.

The software now renders these format options as "text tags"
— such as [B]..[/B] or [COLOR]..[/COLOR]rather than simply displaying the format effects (e.g., as bold or colored text) as was done in previous years.

Moreover, these changes affected hundreds of older, but still useful, posts if they contain such specially formatted macro snippets! (However, not all posts containing macro code have this issue, which adds complexity to finding a workable solution. So far there doesn't appear to be a method that can globally locate the problematic posts to easily remove just the new "text tags".)

How might this affect you?

If you copy any such macro code with these text tags from WordPerfect Universe into your WordPerfect to create a functioning macro (Steps 2-5 below) you might not be successful, depending on where the changes are located in the raw code.

The only solution as of this date is to delete those text tags before you Save & Compile the macro code in Step 5 below. Otherwise, the WordPerfect program will pop an error message and will not compile the macro.

A better solution on the WordPerfect Universe site might be found to reverse these changes, and if that happens this Note will be updated.

Step 2 (of 7)

Select all text from beginning to end, and copy the selection to the Windows clipboard with Ctrl+C (or right-click on the selection and then click Copy).

Note
If you are copying the macro code from WordPerfect Universe, be sure to select the code directly from the main WordPerfect Universe (thread) screen's "Code:" window and not from inside a "Reply With Quote" window.

Here are some screen shots from WordPerfect Universe showing the scrollable "Code:" window in a post containing some "plain text" macro commands:

Example of Code window showing a small macro
Example of Code window with code selected
Example of Code window with code copied (via right-click on selection)

Doing this will eliminate any WordPerfect Universe formatting "tags" (such as [CODE] and [/CODE], [B] and [/B], etc.) that might have been added to the posted macro code. These tags are not macro commands.

[You can, of course, use the WordPerfect Universe Forum's Reply screen — but you should copy only the comments and commands between any beginning [code] tag and ending [/code] tag, since those bracketing tags are not part of the macro's code.] 

Tip

For long macros posted on WordPerfect Universe inside the scrollable Code: window (image), the macro code can extend below the bottom of the visible portion of that window.

Hence it is better to simply click directly on the left side of the first line of code in the Code: window (even though you won't see any cursor appear there), then hold down the Shift key while you tap the arrow keys to "paint" the macro's code from beginning to end.

(Don't just hold down an arrow key or you might overshoot the end of the code and paint other things on the Forum's screen outside the Code: window.)

Then right-click on the selection (or use Ctrl+C) to copy the selection to the Windows clipboard.

Step 3 (of 7)

(a) Open a new, blank document in WordPerfect with File, New.

A WordPerfect macro is really just another form of WordPerfect document (with the special filename extension .WCM), so you will want to start a new one to contain the macro commands.

(b) Click on Tools, Macro, Macro Toolbar to display the Macro Toolbar:

Macro toolbar

This bar has some useful buttons such as "Save & Compile" and "Codes" — both of which you will use later.

(c) Open the Reveal Codes window if it is not already open (View, Reveal Codes).

This helps with the next step.

Step 4 (of 7)

(a) Position your cursor immediately after any codes in the new blank document — typically, this is immediately after both of the [Open Style][Ln Num: On] codes.

The second code is automatically added by the macro toolbar: It displays consecutive line numbers along the left page margin.

Look in Reveal Codes to see where the red block insertion cursor is located, and use the arrow keys to reposition that cursor if necessary, like this:

[Open Style][Ln Num: On]

(b) Then click on Edit, Paste Special, Unformatted Text to paste the plain-text macro commands from Step 2 into the macro document.

Using the Unformatted Text feature will paste the copied material without any extraneous formatting or other unwanted codes.

(c) Optional (but might be required, so please read):

•  PROBLEM: Some essential parts of some commands (e.g., WordPerfect symbols or format codes) might not be completely copied into the macro document — but there's an easy solution (below).

But ... why does this happen in the first place?

Some operational macros contain commands that tell the macro what to do when it looks for, or encounters, a WordPerfect symbol (see Insert, Symbols) or a WordPerfect format code.

The most common place you will see these in a working macro is in a SearchString() and/or a ReplaceString() command's parameter — the part of the command enclosed in parentheses.

However, format codes are "binary codes" and, unlike the rest of the macro command (which are ordinary text characters) they cannot be simply copied and pasted into a web page, newsgroup post, or email. These codes (and some WordPerfect symbols) get stripped out because web sites and email programs — as well as most other Windows programs — do not recognize WordPerfect format codes.

Hence, most authors typically work around this limitation when they post macro code on a web page or newsgroup by using plain text characters as a "placeholder" to represent the binary code.

This text representation is typically a string of text characters enclosed in quote marks for example, a "[HRt]" that represents a hard return format code (which code you can also see in Reveal Codes wherever you pressed the Enter key).

[If there's nothing between the two quote marks e.g., SeatchString("") and you believe there should be something there, see Footnote 1.]

•  SOLUTION:

After you paste the copied macro code into WordPerfect, be sure to replace any such WordPerfect placeholders.

Here's how:

▸  For WordPerfect symbols, see Insert, Symbol (or Ctrl+W) for the entire Symbol Set.

▸  Similarly, any WordPerfect format code placeholders in the SearchString() and ReplaceString() commands (or where otherwise indicated by the author) should be replaced with the actual WordPerfect binary codes from the Codes button on the Macro Toolbar (displayed when you performed Step 3 above).

For example:

When you paste plain-text macro code into WordPerfect and you see a command like this one (i.e., plain text characters without any actual format codes when viewed in Reveal Codes) — 

SearchString("[HRt]") 

— just delete the 5-character text string [HRt] (which here stands for a Hard Return) inside the parentheses. Be sure to keep the two ordinary (i.e., straight, not typographical) double quote marks.

Then in its place, insert the actual binary code between the two quote marks using the Codes button on the Macro Toolbar (image above).

The Codes button pops up a Codes dialog. To insert a hard return code (as in our example) you would scroll down in the long list of codes to HRt and click on it to choose (select) it. You will then see this:

Codes button list showing a HRt code

Finally, click on Insert, then Close.

Result:

In the main editing screen of the macro document you will now see the same SearchString("[HRt]") command displayed on your screen.

However, if you look in Reveal Codes you will see the actual binary code you just inserted between the quote marks:
SearchString("[Macro Func]")

Step 5 (of 7)

[If your code came from a post on WordPerfect Universe, be sure to read the Important Update above.]

Save the pasted material with the Save & Compile button on the Macro Toolbar (the bar below the ruler and above the main text area) -

Macro toolbar

Give the macro a name that will help you remember it.

Notes

¤  This step saves the macro to your Default macros folder as shown in Tools, Settings, Files, Merge/Macro. [Advanced users may wish to save to a different folder, and will therefore need to include the full path to that folder as part of the macro name. (Exception: The macro can be placed in the Supplemental macro folder and the program will find it just by its name.]

¤  The resulting file will have a .wcm filename extension, which WordPerfect will recognize as a macro (assuming it has valid commands inside it), and compile it the first time you play it after creating it (or after editing it).

¤  Messages: If you get an error message when you press Save & Compile, open Reveal Codes and check the pasted text for long lines that may have wrapped into two or more lines with a hard return [HRt] or line break [Ln Brk] between them. Remove the hard return(s) or line break(s) to "glue" the lines back together. [The program will recognize commands that have up to about 512 characters before a hard return. If it is too long you'll see and error message when you try to save the macro.]

Step 6 (of 7)

(a) If the macro is designed to be played in an existing document, open that document if it is not already open.
Many macros are designed to be played without having to open any existing document, in which case you can just play them in any new, blank document such as Document1, Document2, etc.
(b) Play the macro with Tools, Macro, Play (or Alt+F10).

While the macro plays ("runs") a small audiocassette icon should appear in the Windows notification area (a.k.a. the "system tray"):
audiocassette

If it's not visible click the "Show hidden icons" button in the notification area.

This icon is handy in case you ever need to stop (i.e., abort) the macro manually: Just right click on the audiocasette icon and choose Stop.

Step 7 (optional if you plan on using the macro often)

For quick and easy access to the new macro you can assign it to a -

[1] keystroke combination ("keyboard shortcut"),
[2] toolbar button, or
[3] custom menu.

See Customizing WordPerfect here


Tips

☼  Note that the macro can be opened for editing at a later time with Tools, Macro, Edit (or Ctrl+F10). It is just another WordPerfect document — but with the special filename extension .wcm. When you edit it, the Macro Toolbar will reappear to let you use the Save & Compile button to save any changes.

☼  You may need to edit the Application() command at the top of the code (if one exists) to change the language code from "EN" (or "US" or other language) to the language version you are using.

Or, if you are using just one language version of WP, just delete the last semicolon along with the "EN," to get something like this:

Application (WordPerfect; "WordPerfect"; Default)

Note that this type of Application() command is the best way to post your own macro code on WordPerfect Universe (or elsewhere) so that those who copy it (and use some other language edition) won't get an error message when they try to compile your macro code. 

☼  You can delete any instructions, annotations, or comments in the copied material (ie.g., all text following "//" marks up to the end of the line), though usually there is no need to do so (and you may want to keep them for future reference, anyway). Related tip: How to put instructions or comments inside a macro.

☼  For easy access, you can assign the macro to a keystroke combination, a toolbar button, or a menu. See Customizing WordPerfect - Three easy ways to play macros, load programs, type (insert) keystrokes, and use special features by creating your own toolbar buttons, shortcut keys ("hot keys"), and menu selections.

☼  For more information on creating and editing macros, see Need help creating macros and templates?


Footnote 1

[Continued from above...]

Rarely, if a macro author forgot to include a text representation for the command's parameter — or did not include an adjacent programmer comment (//...) to tell you what to do — the parameter's item might be changed to something else, such as a simple "?" or some other "odd" text character.

Worse, the macro might not work as intended or even work at all.

Mistakes happen. In this case, you should contact the author. [Remember: Always play new macros on a copy of your document until you are confident they suit your needs.]