"Ads by Goooooogle" links provided by Google.com, which has sole control over all advertising content it displays on this site.

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

Barry MacDonnell's
Toolbox for WordPerfect

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

Page updated Jan 18, 2008

DeSpacer -

A macro that reduces multiple adjacent spaces to single spaces.
It can also relocate/remove stray single spaces.

Download DESPACER.ZIP (v1.06; 01/18/08; 23, 334 bytes)

Compatible with WordPerfect 8-X3+

Downloading, Documentation, Modifications, and Support

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.

The download ZIP file contains a WPD document (thanks to Don Codling) with various short phrases and sentences that have extra spaces in them. You can use it to see the effects of playing the macro.

This macro will change this -
     "Once     upon a time,     "
to this -
     "Once upon a time,"

Background:

In some documents, adjacent (i.e., contiguous) spaces may have format codes embedded in them, which can present a problem for traditional Find and Replace procedures (e.g., using Edit>Find and Replace to find two spaces and replace them with one space). Using Find and Replace to replace multiple spaces with a single space will remove some (but, curiously, not all) embedded codes, which is something that you probably do not want.

Also, after you delete text or cut-and-paste text to other parts of a document, you could end up with something like this in your document (where <s> indicates a space character):

The<s>quick<s>brown<s>[Bookmark]<s>fox....

Unlike some other macros or Find and Replace methods, this macro won't delete any codes found between space characters. Using this macro, the above line would be processed and look like this in the Reveal Codes window:

The<s>quick<s>brown<s>[Bookmark]fox....

Additionally, any misplaced spaces adjacent to WordPerfect format codes can be relocated (menu option). For example -

The<s>[Und On]quick<s>[Und Off]brown<s>fox....
(The quick brown fox....)

will be changed to this -

The<s>[Und On]quick[Und Off]<s>brown<s>fox....
(The quick brown fox....)

Note: The exceptions to relocating spaces in this way are spaces adjacent to Font (type or size) codes, where users may want spaces in specific locations when a new font or size is applied. Therefore, spaces adjacent to [Font] and [Font Size] codes are skipped during macro play.

The Despacer macro can also delete unwanted single spaces adjacent to certain codes (e.g., [HRt], [HPg], [HCol], [Cell], [Table Off], [Col Def: Off], [Left Tab], etc.) to help "clean up" the document. There may be some (rare) situations where the macro will not remove all such solitary spaces; therefore, a visual inspection may be required.

You can set these options off to leave such spaces alone, and also turn the menu off to speed operation. See the top of the macro's code for instructions.

Tips:

  • You can play the macro on a copy of your document (File, Open, <name>, Open as Copy), then do a comparison (File, Document, Compare) of the copy with the original document to see what has been changed.

Notes:

  • If the macro processes a lot of spaces, you may not be able to undo the change with Edit, Undo (which is limited to 300 levels of undo). Normally, the macro will process the document with just one or a few levels of Undo -- but there may be circumstances where this is not true. Therefore you should either abandon the changes and Close without saving (then re-open the document), or use File, Save As, and save it with a different name.
  • Processing a large document can take time, given the way the macro operates. You may want to play it on a copy of the final draft of your document, after all other edits are done.
  • Extraneous spaces can be almost anywhere in a document. While the author has tested this macro "nine ways from Sunday," there may be cases where spaces are not removed, or are relocated improperly. If so, please contact the author and he will try to solve the problem and make the macro more robust. In light of this, however, it is recommended that you always work on a copy or backup of your document, as emphasized in the following Disclaimer.
Page Top Disclaimer, Distribution, and Privacy Policies