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

Page updated May 21, 2016

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 in

(3) redline and/or

(4) italics.

Note: The boxes must include actual text, not an image of text.

Tips:

☼  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.



Footnote 1

Notes

¤  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 -
vHRt:=NToC(0F90Ah)
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!)
    Quit
EndIf
If(?DocBlank)
    MessageBox(;"Current Document is Blank";
    "This macro requires text that can be processed.";IconStop!)
    Quit
EndIf
// Start at very top of document:
PosDocVeryTop
// Initialize some variables:
vCount:=0  // Loop counter (for messagebox)
vBoxNum:=1  // Box numbers
vNBoxes:=?BoxCount
// If there are no boxes of any type, exit now:
If (?BoxCount<1)  Go (End@)  EndIf
// Loop through boxes, processing only text boxes:
While(vNBoxes>0)
    If(vBoxNum>vNBoxes) Break Endif  // If no more boxes, exit
    Label(Start@)
    BoxEdit(vBoxNum)
    // 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
        BoxEnd(Cancel!;Hide!)
        // Increase the box number to edit:
        vBoxNum:=vBoxNum+1
        Go(Start@)  // Loop back an process next item
    EndIf
    vBoxNum:=?BoxNumber
    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.
    //
    SelectMode(Off!)
    // Exit from the box:
    While (?SubStructure)  SubStructureExit  EndWhile
    BoxEnd(Save!;Hide!)
    vBoxNum:=vBoxNum+1  // Increase the box number to edit
    vCount:=vCount+1    // Increment number of boxes processed
Endwhile
Label (End@) // Exit from macro here:
If (?GraphicSelected)  BoxEnd (Cancel!; Hide!)  EndIf
PosDocTop  Display(On!)
If(vCount>0)
    Messagebox(;"Finished";"Processed ^0 text boxes";
    HasParameters!; vCount)
Else
    Messagebox(;"Finished"; "No text boxes were processed")
Endif
Return

// Macro code ends here