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

Page updated Nov 12, 2011
DELCODES - Two macros to (1) delete one or more menu-selected format codes; and (2) delete "empty" pairs of format codes

Download DELCODES.ZIP (04/07/2010; 18,810 bytes)

Compatible with WordPerfect 7 and later versions

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

Downloading, Documentation, Modifications, and Support

Disclaimer, Distribution, and Privacy Policies

[Both macros are based on John Land's public domain macros.]

DELCODES.WCM deletes selected format codes from a document such as [Bold On], [Hypertext Begin], [Para Spacing], [Tab Set], etc.

A menu ( screen shot ) lets you select one or more codes from a list of codes.

Many of these codes are actually the beginning code that is part of a pair of codes surround text; deleting the first code will automatically delete the second (ending) code. Other codes, such as [Tab Set], are strictly single codes and are not part of a pair.

The list of codes presented in the opening menu can be modified in the macro code (see "Modifications" below). Tip: See also the (separately downloadable) DelCodes2 macro in the Tips section below.

DELPAIRS.WCM deletes pairs of "empty" attribute or appearance codes such as [Und On][Und Off] that may have been left behind in a document after editing. They are "empty" because there is no text between them. DELPAIRS is very useful in cleaning up clutter in the Reveal Codes window.



Tips and alternatives

  • To delete all codes in a selection of text you don't need a macro. Simply select the text and copy the selection to the Windows clipboard (usually with Ctrl+C). Then immediately paste the copied (and still selected) material back in place with Edit, Paste Special, Unformatted text -- overwriting the original material. This strips out all formatting codes.
    • Note that in WordPerfect 11 and later versions this process converts [- Hyphen] codes to regular character hyphens ("-") and [HSpace] codes to regular spaces. For more information on this, as well as for a macro (and some shortcuts) to facilitate the pasting process, see here.
  • To delete most codes (but not all codes) in a selection of text, download DelCodes2.zip (02/14/11; 7,533 bytes). This macro is similar to DelCodes.wcm, but it does not have a pop up menu to choose codes. You will need to open it (Tools, Macro, Edit) to do a simple edit for any codes you wish to retain in the selection of text. The default is to retain bold and italics, but you can change this. See the instructions and comments at the top of the macro.
    • Tip: For those using WestLaw or WestLawNext, Jim Shackleford had modified this macro to use it with those programs. See this post on Wordperfect Universe.
  • For a macro that can clean up extra codes inserted when you import a Microsoft Word document, see Mike Koenecke's Word Cleanup macro, park of his MAKMacros suite.
  • To change certain format codes (e.g., underlines) to other format codes (e.g., italics), see Ron Hirsch's Replace Codes - Plus on this site.

Modifications

The DELCODES.WCM macro can be modified to include (or remove) codes from the menu list. Simply open the macro with Tools, Macro, Edit. Scroll down to the area that contains this instruction:

"Code list - the format is a text label typed into the left column, than a tab, then a code is inserted in the right column (codes are entered with the Codes button on the Macro Toolbar) - open Reveal Codes to more accurately see the format on a particular line below. Note the use of semicolons (not colons)."

Directly under that paragraph you will see a list of codes in two columns, like this:

Global vItemList[]= {
{"[Bold On]"; "
[Bold On]"};
{"[Bookmark]"; "
[Bookmark]"};
...
{"[Wrd/Ltr Spacing]"; "
[Wrd/Ltr Spacing]"}
}

You can follow the same pattern to add more labels and codes. Note two things:

1. The items in red (in the right-hand column) are codes and must be inserted using the Codes button on the Macro Toolbar that should be visible (if it is not, click Tools, Macro, Macro Toolbar). Then the macro will be able to find them if they exist in the document. The items in the left-hand column are merely text labels for the macro's menu list. The two items are separated with a Tab.

2. The very last line item (see [Wrd/Ltr Spacing] above) in the list does NOT end with a semi-colon. All other lines MUST end with one (semi-colons are used as separators).