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

Page updated Apr 5, 2023

DELCODES - Three macros to play in the current document that can remove unwanted codes

DelCodes.wcm [below] -
Deletes all format codes of one or more user-chosen types (bold, underline, tab set, etc.).

DelExtraHR.wcm [below] -
Deletes all multiple adjacent hard return codes and replaces them with one (or two) hard return(s) at those locations.

DelPairs.wcm [below] -
Deletes all "empty" pairs of format codes regardless of type (i.e., "orphaned" code pairs).

All three macros are in the same download ZIP file (see below).

Download DELCODES.ZIP (10/29/22; 30,698 bytes)

Compatible with WordPerfect 7 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

Disclaimer, Distribution, and Privacy Policies

[DelCodes and DelPairs are based on John Land's public domain macros.]

Related pages -

For an overview of WordPerfect format codes (and some Tips and Tricks) see Reveal Codes.

Code2Txt - Change attribute codes (e.g., [Bold]) to text markers (e.g., "<B>") and vice versa

DateRepl - Change all [DATE] codes (dynamic dates) to text (static dates)

DeSpacer - Reduces multiple adjacent space characters to single spaces without impacting any embedded codes. It can optionally relocate/remove stray single spaces

Replace Codes (see Notes and Tips in the next column -->)

ReplStyl - Replace one style with another, or remove a style's codes

DelCodes.wcm (Updated 10/29/2022: v1.05 - included in download):
Deletes all format codes of one or more chosen types
from a document, such as [Bold On], [Font Size], [Hypertext Begin], [Para Spacing], [Tab Set], etc.

When you play the macro a menu appears (screen shot) to let you choose one or more code types from a list of codes by clicking on their names.

Alternatively you can click a button to choose all codes in the list (see also the Tip below to delete all codes without using a macro).

[New in v1.05:] A checkbox lets the macro process all locations in the document -- including headers, footers, footnotes, endnotes, text boxes, and other such "substructures". (The check box's initial setting is blank (empty), in which case only the main document areas will be processed. Simply enable (tick) the box to include all areas.)

You can play the macro more than once on the same document.

Note that not all possible format codes are listed on the menu to keep the list relatively  short, but you can amend the list to customize the macro: See the Modifications section below.

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

Note also that certain format codes can act as "containers" for other codes and even text -- such as [Delay], [Char Style], and [Para Style] codes. If you choose to delete these codes the macro will pop up a message to alert you and let you choose to continue or exit the macro. This should help you avoid deleting these "container" codes which you might want to retain. (They can be opened for editing or to simply view their contents, as explained on the Styles page.)

-►  Be sure to see the Notes and Tips section below before using this macro.

DelExtraHR.wcm (Updated 04/28/2020: v1.11 - included in download):
Replaces all multiple adjacent hard return
codes ([HRt] with either a single hard return or two hard returns in the main body text area of the current document.

Purpose and operation

This macro can be useful in cleaning up a document so that there are no extra spaces due to extra adjacent hard return codes between paragraphs.

When you play the macro a simple 2-option menu appears (screen shot) to let you specify the number of inter-paragraph replacement hard returns (1 or 2) to use at each of the locations found.

Optionally you can delete any single hard returns that might exist immediately following paragraph styles (such as the built-in Heading styles).

The macro then processes the entire document. The changes made to your document can usually be undone with Edit, Undo (or Ctrl+Z), but it's always a good idea to make a backup of the document before playing the macro.


Other types of "extra" spacing between individual paragraphs can exist

•  In addition to creating extra spacing with the Enter key, extra spacing between paragraphs can sometimes be caused by a format code produced by a setting in Paragraph, Format, Paragraph.
    Check to see if you have set that feature to add extra intra-paragraph spacing. (That setting adds a [Para Spacing] code to the beginning of the  paragraph where it was first enabled.)

•  Extra spacing between paragraphs can also be due to hard returns included inside a [Style] or [Delay] code.

But in the case of applying a Paragraph Style (such as a Heading style) in the document, you might have also used the Enter key to add an extra [HRt] followingthat paragraph style ([Para Style]) code -- effectively producing a blank line between the paragraph style's text and the beginning of the following paragraph.
    If you decide you don't like the extra space at those locations, this macro can remove such extra hard returns quickly by using a checkbox option on the macro's menu -- either at the same time you play the macro to remove ordinary extra hard returns, or by playing the macro again and enabling (ticking) that checkbox. (In the latter case you probably want to be sure to choose the same number of hard returns to replace as you used during the first play of the macro.)

In the case of other types of [Style] codes or in the case of [Delay] codes, you probably will need to manually edit and examine these items (double-click on their codes) if you still see extra spacing between paragraphs.


This macro does not process hard return codes inside headers, footers, footnotes, endnotes, WP comments, text boxes, etc. It only works in the main body text area of the document.


You can set the desired number of replacement hard returns (one or two) for each location, and set an option to also remove hard returns that might immediately follow a paragraph style -- such as a Heading style. See the User Modification Area at the top of the macro's code. (Paragraph styles already contain a built-in hard return; any following [HRt] code simply produces an empty line immediately after that style's text.)


What about temporary hard returns ([THRt])? The answer is found in an old Corel Knowledgebase article. See Footnote 1 below.

DelPairs.wcm (Updated 05/28/2019: v1.04a - included in download):
Deletes all pairs of "empty" attribute or appearance codes
such as [Und On][Und Off] (and 17 others including highlighting) that may have been left behind (orphaned) in a document after editing.

It can be very useful in cleaning up "code clutter" in the Reveal Codes window.

These paired attribute codes are considered empty if there is no text or other material (spaces, text, symbols, etc.) between them.

Note that if there are any [Bookmark] codes or [Style] codes between the pair of (presumably) "empty" on/off attribute codes, the macro will not consider the pair empty and it will skip over that pair since you probably will not want these other codes deleted.

To see the results of using this macro, open or create a short test document with a few lines of text. Open the Reveal Codes window with View, Reveal Codes.  Enter some empty code pairs at the cursor location by simply pressing Ctrl+B (bold), Ctrl+I (italics), etc. Then play the macro.

Empty code pairs to be processed can be seen in the macro code (in the ForEach..EndFor segment). Just open the macro with Tools, Macro, Edit. If a particular paired code is not found the macro skips to the next pair in the list untill all specified pairs are searched and processed.

[v1.02 adds code to take into account the state of the Reveal Codes window, and also displays the total number of deletions. v1.03 adds [Color][Color] pairs. v1.04 removed [Color][Color] codes due to complexities in some documents' formatting.]

Notes and Tips

•  To change certain format codes (e.g., underlines) to other format codes (e.g., italics), see Replace Codes on this site.

That macro can quickly search for a user-chosen text attribute (the responsible format codes are visible in Reveal Codes) and then changes it to something else (i.e., replace it, add to it, or remove it). For example it can change underlined text to italic text. There are 16 attributes to search from a drop list on the macro's menu. It can also pause at each item found to get your confirmation.

•  Some format codes in a document might be included inside certain other codes (e.g., inside [Delay] codes and/or some [Style] codes), which act as "containers" to apply the formatting (and sometimes, text characters) at specific points in the document.

This happens (e.g.) when you decide to delay the onset of some formatting with Format, Page, Delay Codes. Sometimes it can be done automatically by the program itself. (See the Delay Codes page for more information.)

Hence, if you selected codes on the DelCodes.wcm menu that might also be found inside these special container codes, the menu-selected code instances inside them will not be deleted -- unless, of course, you delete the "container" code, too.

[This often useful program code-hiding feature can impact your Find and Replace operations, too, since F&R does not search inside delay codes or styles. These special codes must be manually opened (double-click on them in Reveal Codes) to view their contents and/or remove unwanted format codes that might be inside them.]

•  To delete all codes in a document or in a selection of text you don't need a macro.

There are at least two ways to do this depending on the amount of text to process.

Method #1

For the entire document:

Use File, Save As to save the entire document as a special "File type" (see the bottom field in the File, Save/As windows):

ANSI (Windows) Generic Word Processor retains Tab codes; converts Indents to Tab codes; retains WP's end-of-line SRt codes to preserve word wrap.

   - or as -

ANSI Windows Text — removes ALL format codes; ends each line with a HRt code; converts Tabs/Indents/Margin indentation to space characters. (To remove such extra adjacent spaces see the DeSpacer macro here.)

Method #2

For a selection of text:

If you want to strip out format codes from the current selection of material (even the entire document if selected) to produce "pure text"-

- first copy the selected text to the Windows clipboard (typically with Ctrl+C), then

- immediately paste the copied text back in place (or into another document) with Edit, Paste Unformatted text (in some early versions use Edit, Paste Special, Unformatted text).

Be aware this can change some format codes you might wish to retain such as (in WP11 and later versions) hard spaces, regular hyphens and soft hyphens. (See http://wptoolbox.com/tips/PSpecial.html for more.)

Still, this can be a useful technique, especially to convert outlines and numbered/lettered/bulleted lists to their plain-text versions.

See also "Be careful about deleting [Bookmark] codes" below.

•  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 by design (for speed) it does not have a pop up menu to choose codes. Hence 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.

•  To delete one type of code in a document you don't need a macro. (It might be best to position your cursor at the very top of the document first.)

Simply use Edit, Find and Replace, and choose the code from the F&R's Match, Codes menu. Or you can just copy that code from the document into the F&R field, as noted in the F&R tips page here.  
Then choose <Nothing> in the Replace field.

Also be aware that some codes have both a On and an Off code; if you delete one, the other is also deleted. [For more Find and Replace tips, see here.]

Tip: To delete a specific font code (e.g., Arial) you will need to specify the font code in the F&R dialog: Click on Edit, Find and Replace, Type (on the F&R menu), Specific codes, Font, OK. Then choose Arial and be sure to check the box to "Replace with Nothing". Then click Replace All (if you wish to delete all of them).

Related tip: To change all fonts and/or font sizes in a selection of text (you can even select the entire document first, if desired) to a single desired font face and/or font size, just apply the new font and/or size to the selection from the Font Face (and/or Font Size) field on the Selected Text property bar (which should appear when text is selected).

(Note: Even if your replacement font/size is shown as the current choice in that property bar's Font Face or Font Size field, you should still expand the relevant field and then click on your desired replacement to choose it.)

This causes the selection to be bracketed with a pair of [Font] and/or [Font Size] codes, effectively replacing all other existing [Font] and/or [Font Size] codes inside the selection.

Related tip: To delete a specific Font Size code
such as deleting a [FontSize: 10p] code wherever it appears in your 12-point document (including such specified font size codes found inside headers, footers, notes, text boxes, etc.) you can use either the manual method or a small macro.

Manual method

[1] Place the cursor at the very top of the document before all text and codes.

[2] Click on Edit, Find and Replace (and verify that Options, "Include Headers, Footers..." is enabled if you want these structures processed; if not, disable this option).
Then click the Type tab.
Then click Specific Codes, Font Size, OK.
This opens the "Find and Replace Font Size" dialog.

[3] In that dialog, specify the point size to find (in the top drop list), and check (tick) the box "Replace with Nothing" to delete that specific font size code.

[4] Finally, use the buttons of the right side of that "Find and Replace Font Size" dialog to find and replace them.

Macro method

First be sure to adjust the FontSize() command below for the specific font size code (in points) you want to delete.

// Macro begins here
// Globally removes ALL specific [FontSize] codes of

// the specified point size from the current document

If (?Substructure or ?GraphicSelected)
FontSize (10p)  // (<- change the point size as needed)
ReplaceForward (Extended!)

// Macro ends here

Tip: To copy this code into your WordPerfect program to create a working macro see here.

•  Be careful about deleting [Bookmark] codes since you, the program, or a macro might use them to locate various parts of the document as part of some type of automation task.

•  For a list of format codes with brief descriptions see this thread at WordPerfect Universe: "Reveal Codes list (in PDF format)".

New in 2016 for WordPerfect X8: The Corel site has a similar PDF ("WordPerfect Reveal Codes Chart") on their download page here. Presumably, Corel will continue to provide this list for future versions.


The DelCodes.wcm macro can be modified to include (or remove) codes from the menu list.

[1] Simply open the macro with Tools, Macro, Edit.
This opens the macro for editing and displays the 9-button Macro Toolbar (i.e., a special property bar):
Macro Toolbar

[2] Then scroll down to the area that contains instructions:

"To add to the Code list ..."

Directly under the instructions in the macro's code you will see a list of format codes in two tab-separated columns, like this abbreviated version:

Global vItemList[]= {
{"[Block Pro On]";        "[Block Pro On]"};
{"[Bold On]";               "
[Bold On]"};
{"[Bookmark]";            "
{"[Very Large On]";      "[Very Large On]"};
{"[Wrd/Ltr Spacing]";    "
[Wrd/Ltr Spacing]"}

The left column contains text labels for the macro's menu list; the right column contains the actual format codes that correspond to each label.

[3] You can follow the same pattern to add or remove more labels and codes. Note these things:

The very last line item (e.g., see [Wrd/Ltr Spacing] above in the sample list) does not end with a semi-colon. All other lines must end with a semi-colon.

Adding new items to the macro's list:

The items in the right-hand column are codes and must be inserted between double quotes using the Codes button on the Macro Toolbar that should be visible (see image above; if it is not visible 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 typed into the macro code and used the macro's menu list (they can be any text characters). The two items are separated with a Tab for better visibility when editing the macro.

Removing items from the macro's list:

You can, of course, simply delete the item's row (i.e., the label and its code in the left and right column, along with brackets and tabs on that line), but it might be better to simply disable the item so it can be used later if desired:

Just precede the line item with two forward slashes (//). This turns the line into an inactive comment. [Side note: This was done in the alternative DelCodes2 macro in the Notes and Tips section above.]

For example, to disable the [Bookmark] item on the list:

//{"[Bookmark]";            "[Bookmark]"};

You might want to add color or highlighting to any disabled items so they are more apparent when editing the macro in the future. (Reminder: Always be sure the last item in the list does not end with a semi-colon, as mentioned above.)

[4] When done editing, save your changes with the Save & Compile button on the Macro Toolbar.

Footnote 1

[...Continue from above...]

From an old Corel Knowledgebase article:

[THRt] Codes Appear in a Document and Cannot be Deleted
Article ID: 19484  Revision Date: November 02, 1998

Text inserted on a line followed by a paragraph formating code (IE., Table, Columns, etc) cause a THRt codes to appear in a document. This code cannot be deleted.

The THRt code is a Temporary Hard Return Codes. It is a paragraph formatting codes [sic] which act the same as [SRt] Soft Return codes. The code was entered by the program because whatever formatting follows that code must appear at the beginning of a line. This is working as designed.

For example: If the word "Test" is typed and a table is created directly after the word "Test" (with the cursor on the same line) a [THRt] code will be inserted after the word "Test." This is because WordPerfect requires a table to begin on a new line. WordPerfect will remove the THRt code when the formatting is changed or in this instance the table is moved to a new line.

[From WordPerfect Universe here. Emphasis added.]