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-2021 by Barry MacDonnell. All Rights Reserved.

Page updated Feb 17, 2017

Macro setup - a macro that formats any document with a custom "macro editing style" (line numbering, etc.)

Download MACSETUP.ZIP (02/17/2017; 8,152 bytes)

Compatible with WordPerfect 8 and later versions

WordPerfect 11 users: See important information about using macros in the first release of WP11 ( at the top of this page.

Downloading, Documentation, Modifications, and Support

(This macro probably is most useful to macro writers.)


Macro Document Setup.wcm sets up the current document with a custom (but user-modifiable) format for writing or editing macro code. See "How it works" below.

It can be played in a blank document or in an existing macro file (.WCM).

The technique might also be useful in storing ("hiding") formatting codes inside the document's initial [Open Style: DocumentStyle] code -- the first code you see in Reveal Codes at the very top of the document. See "Tip" below.

How it works

This macro formats the currently open document with

  • a custom font (Arial),
  • font size (10-point),
  • line spacing (1.1)
  • tab setting (0.25" each tab) and
  • line numbering (8-point, light gray color).
  • It also displays the Macro Toolbar, then it inserts IfPlatforma/EndIfPlatform commands to allow bracketing the programmers's comment area at the top of the page; in effect, this technique lets you insert initial comments without having to precede each comment with "//".

☼  These items are set up inside the document's initial style with the Styles Editor to "hide" them from casual editing.

How to modify the results and the macro itself

¤  To edit the font, font size, tab setting or line number changes made to a document's body text area after the macro plays, use File>Document>Current Document Style -- not File>Document>Default Font, which will not override existing font or font size codes that are inside the Styles Editor (they are "downstream" from the Document Default Font dialog settings and therefore take precedence).

¤  You can modify the default values of the macro in the redlined areas of the macro code (Tools>Macro>Macro Edit). You can also remove the message that pops before the macro exits.

Tip - Using it for other purposes

Some things cannot be created inside a style (with the Styles Editor), but it might be possible to create them in a document's body text area, then copy the codes to the Contents field of the Styles Editor. For example, it is possible to create a [Delay] code in a document, then cut (Ctrl+X) the code to the clipboard and paste (Ctrl+V) it into the document's Open Style.


Reset page margins on page 2 and following pages back to the default (or some other setting), and hide this process inside the initial document style.

This can be done with a macro for the current document, or it can be done in a template such as a letterhead template.

Step 1. Put the cursor at the top of page 1, then click Format, Page, Delay Codes. Accept the "1" in the "Number of pages..." field and click OK.

Step 2. In the Define Delayed Codes window that appears, click Format, Margins (or click the Page Setup or Page Size button).

Step 3.

WordPerfect 9 and earlier - In the Page Setup dialog that appears, set new margins or accept the default of 1" for all margins, then click OK. Go to Step 4.

WordPerfect 10 and later - If you have not changed any margins on page 1 but you want to ensure that margins are always set back to the 1" default on any second or subsequent page, follow the instructions in the next paragraph. If you have changed any margins to a new value on page 1, you should not need these instructions (but please read them before going to Step 4).

In the Page Setup dialog that appears, change any of the margin settings a small amount, then click OK. This will insert all four margin codes in the Reveal Codes window of the Define Delay Codes screen. Then change the margin settings back to your default (1") or to some other setting. This extra step of changing margins a small amount in Define Delay Codes, then resetting them to the desired amount, is a workaround for a small bug in WP10/11/12. In WP9 and earlier versions the program would insert the four margin codes -- with a default 1" setting -- by simply clicking OK in Page Setup. If you just click OK in WP10/11/12 to try and insert default margin settings, nothing happens: no codes are inserted.

Step 4. Click Close to exit from the Define Delay Codes window. In Reveal Codes, you should see a [Delay] code on page 1. Normally you should move the cursor past this new code before beginning typing your text so as not to push the code to another page.

Step 5. "Hide" the the [Delay] code so it is less likely to be moved or deleted accidentally: Open Reveal Codes, select just the new [Delay] code, cut it to the clipboard with <Ctrl+X>. Then double-click the initial [Open Style: DocumentStyle] code at the top of the document; this opens the Style Editor; paste the [Delay Code] into the Contents field, then click OK. (Just remember to look inside the initial style code if you need to revise or delete the [Delay] code!)