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

Page updated Oct 25, 2017

BOX2TEXT - Converts text inside text boxes to body text

Download BOX2TEXT.ZIP (v1.02; 12/13/15; 8,557 bytes)

Compatible with WordPerfect 8 and later versions

Downloading, Documentation, Modifications, and Support

A macro that moves all text inside each text box in a document to the current box's position in the document, then deletes the empty box.

There are options to

(1) remove formatting by pasting as Unformatted Text,
(2) pause for confirmation, and/or paste the text into the document in
(3) redline and/or italics.

Note: The boxes must include actual text, not an image of text. Any box that is not actual text (e.g., images) will be skipped.


☼  You can paste any selected/copied text as Unformatted Text. Such text will be "plain" text and will take on the formatting at the insertion point (i.e., it won't bring along old formatting from the source).

☼  See LETRBOX and TEXTBOX to create rounded-edge text boxes around a single character or symbol, or around selected words/phrases. (If desired, you an turn them back into plain text with Box2Text.)

☼  Instead of converting text inside text boxes to body text, you might need to retain the box structure but change the text's formatting.

For example, if you used text boxes to format section headings for stylistic reasons, you might want to change the font or font size in the boxes, make them bold or italic, add a color, etc. This can be done with a similar macro to Box2Text.

But since such a macro would need to be customized to suit your exact needs (fairly easy to do), an example macro in "raw" code is given below, in Footnote 1.

(Note - perhaps of interest to macro writers: Sometimes the font in a text box will be set to the same font type as existed in the template that spawned that document. See Footnote 2 for more information.)

Footnote 1


¤  Based on the author's Box2Text macro, the Change text box format.wcm macro below is in "raw code" form.

¤  To copy the raw code into your WordPerfect program to create a working macro, see here.

Purpose and instructions

This macro changes the format of text in all text boxes in the main editing screen areas (i.e., "body text" areas). Note that unlike Box2Text above it does not have  the option to pause for confirmation. However, that option can be added in a similar way to Box2Text.

Examine the code below. Set your preferred font size, etc., in the bolded commands below. To disable a format command, add two slash marks ("//") before the command (similar to the various comments you see in the code).

If you have text inside a box(es) that has special formatting interspersed in the text—e.g., a font size change—and you do not wish that particular text to be converted to the new font size, then disable the SelectAll command just above the aforementioned bolded commands. This will place the new font size code at the beginning of the text contents stream, and not apply it to the entire contents.

// Macro code begins here

// Name: Change text box format.wcm
// Purpose: Changes the font size and appearance (bold, italics) in all text boxes.
// Author: Barry MacDonnell, http://wptoolbox.com

OnError (End@)
// Display messages if needed -
If(?Substructure or ?GraphicSelected)   
    MessageBox(;"Not At Main Edit Screen";
    "This macro can be started only from the main editing screen."+vHRt+vHRt+
    "Exit from any header, footer, footnote, text box, graphic,"+vHRt+
    "WordPerfect comment, etc., and play the macro again.";IconStop!)
    MessageBox(;"Current Document is Blank";
    "This macro requires text that can be processed.";IconStop!)
// Start at very top of document:
// Initialize some variables:
vCount:=0  // Loop counter (for messagebox)
vBoxNum:=1  // Box numbers
// If there are no boxes of any type, exit now:
If (?BoxCount<1)  Go (End@)  EndIf
// Loop through boxes, processing only text boxes:
    If(vBoxNum>vNBoxes) Break Endif  // If no more boxes, exit
    // Test the box's type:
    // Note: "1"=Text box; if not a text box, exit segment and loop back:
    If (?BoxContentType <> 1)
        While (?SubStructure)  SubStructureExit  EndWhile
        // Increase the box number to edit:
        Go(Start@)  // Loop back an process next item
    BoxContentEdit  // Edit the text box to select its content
    SelectAll  // Apply change to entire contents in the box
    // Here is where the formatting of the box's contents is changed:
    FontSize(14p)  // Change the font size in the text box to 14-point size
    AttributeAppearanceToggle(Bold!)  // Add bold
    AttributeAppearanceToggle(Italics!)  // Add italics
    // See Macro Help for other commands you can use here.
    // Exit from the box:
    While (?SubStructure)  SubStructureExit  EndWhile
    vBoxNum:=vBoxNum+1  // Increase the box number to edit
    vCount:=vCount+1    // Increment number of boxes processed
Label (End@) // Exit from macro here:
If (?GraphicSelected)  BoxEnd (Cancel!; Hide!)  EndIf
PosDocTop  Display(On!)
    Messagebox(;"Finished";"Processed ^0 text boxes";
    HasParameters!; vCount)
    Messagebox(;"Finished"; "No text boxes were processed")

// Macro code ends here

Footnote 2

[Continued from the note above...]

[Perhaps of interest to macro writers:]

Sometimes the font in a text box will be set to the same font type as existed in the template that spawned that document. 

From a thread
["Search and Replace Text in Text Boxes"] posted here on WordPerfect Universe between Roy "lemoto" Lewis, Joe Fox, and myself:

"... I wonder if Text boxes and Graphic captions share something that other substructures such as headers and footers do not: They can be influenced independently by File>Document>Default Font and Format>Font>[Settings].

As you remarked about my earlier post (to which you linked), this may be yet another reason to change the default font in a document -- and all its substructures -- only with the Styles Editor (for the [Open Style]) or with File>Document>Current Document Style. And as I noted in that post:

... if you directly edit the Open Style by either double-clicking the [Open Style: DocumentStyle] code at the top of a document or by using File, Document, Current Document Style, then you can change the font or font size and you can visually check that the codes were changed in the Styles Editor (that is now open) by viewing the Contents field. ...

Since I found in my tests (above: current thread) that an older document, probably based on an older template, seems to internally retain the default font specifications from that older template, it would appear that macro writers should consider taking the proactive step of always forcing any text's font inside a Text box or Graphic caption to the one they desire, and not rely on the font being the same as the document's main body text. It might not be the same.

So my recommendations are:

1. Always set the default font for a document either (a) by directly editing the Open Style by either double-clicking the [Open Style: DocumentStyle] code at the top of a document, or (b) by using File, Document, Current Document Style. Do not use File>Document>Default Font or Format>Font>[Settings] for this task.

2. When using a macro to edit a Text box or Graphic box, consider forcing (i.e., set) the font there to the one you want, and do not assume it always will be the same as the font in the body text area. (The latter can be stored in a system variable, ?Font, so the macro could use that font in the text box or Graphic caption.)

Both recommendations do not seem to have a downside, so it cannot hurt to use them all the time, "just in case"."