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

Page updated July 23, 2021

Splitter - A macro that splits the current document into two or more sequentially numbered files on your disk

Download SPLITTER.ZIP (v1.01; 07/24/21; 17,626 bytes)

Written in WordPerfect X5 and updated in WordPerfect 2020, but should be compatible with other 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

See also Clipper - A macro that lets you select material in the current document (or any open WP document) and automatically clip (copy or move) it to a separate temporary document.

Purpose


Splitter.wcm (v1.01)
will save specified portions of the current on-screen document into several separate and sequentially numbered files on disk, such as -

001 MyNewDocument.wpd
002 MyNewDocument.wpd
...
999 MyNewDocument.wpd

        or

MyNewDocument_001.wpd
MyNewDocument_002.wpd
...
MyNewDocument_999.wpd

The Splitter macro might be particularly useful in preparing to create subdocuments from a single file in preparation for using WordPerfect's Master/Subdocument feature. [Later, the subdocuments can be automatically added to the Master with a macro such as the MakeSubs macro in the Library.]

The current document is not affected since the macro simply copies selections, delimited by your specified separators, and saves the selections in new, sequentially numbered files in your specified storage folder.

(Note: If the numbered filename already exists in that storage folder it will be replaced. An optional message will pop up to alert the user to this situation, but it is better to move or rename these files before using the macro again.)

The position of the file's number — before or after the root filename — can be specified, as well as its padded number size, beginning number, etc. (see below).

If you just need to clip parts of any open document into a separate on-screen document, see Clipper.

Instructions

Download and extract the macro from the ZIP file (◄- left sidebar), and place it in your default or supplemental macro folder. (See the "Downloading..." link in the left sidebar if you need help.)

Make a copy of your original document as a backup. Then -

[1.] Insert temporary "separators" into the current document.

Place a WordPerfect symbol (with Ctrl+w) or any special character string not otherwise used in the current document (e.g., @#$%) at the end of every section you wish to save as a separate new file.

Be sure to include one separator at the very end of the current document if you wish the last section of the document to also be included as a file in the storage folder (described in step 2).

Careful placement of the separators is recommended. You probably do not want to split material that belongs in the same new file, so be aware of anything that connects one item to another further down in the current document, such as footnotes, endnotes, cross-references, headers, footers and watermarks.

Even with close attention to where the current document should be split, you might still need to edit the split documents to reestablish the placement and function of these "spanning" items.

Example: Headers are started on a given page and only display on subsequent pages until stopped or replaced. Splitting a document containing a preexisting header into another document qualifies as "stopping" the header in that new document. Solution: Just copy the original header's contents into a new header in the new, split file.

Notes

☐  The macro will start from the top of the document and select everything up to — but not including — the first separator. It will then save that selection to a new, numbered file on disk. It then skips over that separator and repeats the process, thereby splitting the current file into the desired sections, each in its own new file on disk.

☐  Here, the default separator expected by the macro is a single heart symbol (i.e., which is symbol 5,0 using Ctrl+w), but you can use any other symbol or symbols. (See also step 5 below.)

☐  The current file is not affected by the splitting process. But note that it will still contain the separators you inserted. These can be removed with Edit, Undo or by simply closing the original without saving it — or if it's a copy of the original, the copy can be discarded.

Then, modify the macro. (A WordPerfect macro can be opened and saved like any other document.) Normally, the next steps are a one-time procedure and is easy to do. [Tip: You can make multiple copies of this macro, named differently, where each is set up for a different task.]

[2.] Create a special storage folder on your computer to contain the new files.

Use Windows File Explorer (or similar file manager) to create the new folder in any convenient location.

The folder can be named anything but generally you will want to use a fairly short path to it and a short folder name.

[3.] Enter the full path to that storage folder at the top of the macro's redlined User Modification Area. Be sure to include the drive letter.

For example, the default used by the author is -

    C:\Users\Barry\Documents\Temp2\

You can also change the root portion of the filenames — i.e., the part without the incrementing number — and/or filename extension (.wpd is the default) to use for the new files to be stored in that folder. (See the User Modification Area.)

[4.] Specify the File Type for the split files in the User Modification Area. You can choose one of four types to use for the split files:

•  WordPerfect (.WPD) (<= the default)
•  Rich Text Format (.RTF)
•  ANSI Windows Text (.TXT)
•  ANSI (Windows) Generic Word Processor (.TXT)

Notes

You should always test the output of these choices by opening the resulting split files in their intended program (e.g., WordPerfect, WordPad, etc.).

☐  The WordPerfect file type of split files should be identical (or nearly so) to the original document's selected segments. Some manual editing of split files may be required in complex documents (e.g., if a footnote/endnote/cross-reference calling number is in one split file and the note/reference is in a subsequent split file).

☐  The Rich Text Format (see Wikipedia for more) file type retains text attributes (e.g., bold), graphics, hypertext links, tabs, indents, word wrap, etc. However, it strips out WordPerfect styles (e.g., Heading styles) and the text to which the style was applied when the split file is opened in another program (e.g., WordPad). Hence, some editing of these split files may be required.

☐  The ANSI Windows Text type is what you might expect in Windows NotePad and similar plain text editor: It strips out almost all WordPerfect formatting (replaces tabs and indents with spaces), and there's no word wrap.

☐  The ANSI (Windows) Generic Word Processor type also strips out WordPerfect formatting but retains Tab codes, converts Indents to Tab codes, and retains WordPerfect's end-of-line SRt codes to preserve word wrap.

In many instances this choice produces a preferred "plain text" output since its content is often closest to the content (minus most formatting) in the original WordPerfect document.

[5.] Enter the same symbol(s) or character(s) (discussed in step 1 above) in the User Modification Area — see the vSplitter variable there.

The macro uses the value stored in this variable to search for the same symbols or characters in the document itself.

Recommendation

Try to use a single symbol or character as the separator — although the macro should compensate for multiple symbols/characters.

If you use multiple characters, you need to be sure that the full string of symbols exists at each separation point in the document (as separators) and in the macro itself (in vSplitter).

[6.] Set any other macro options in the User Modification Area.

[7.] Save your changes to the macro with Save & Compile on the macro toolbar (image) or with File, Save.

Play the macro on any open file that has the appropriate separators (step 1 above) in it.

Tip: Once the separate files are created they can be used as Subdocuments in a Master document (See MakeSubs in the Library.)

Notes, cautions, and tips


  The macro starts from the very top of the document, and creates newly numbered files in sequence.

Reminder: The new files should then be edited to make sure they contain the proper text, formatting, etc.

Changes in formatting are sometimes the result of placing the separator in the wrong location in the original document, or because of changes in formatting above the separator location(s) that carry (or fail to carry) forward into the new, split document. Use Reveal Codes to relocate any such separators.

Methods exist — such as using WordPerfect custom styles at the top of each document — to ensure formatting is consistent across several related documents. [See (e.g.) the tips on the MakeSubs page — particularly Charles Rossiter's tip here, which also applies to documents split (copied) from a source document.]

☐  By design, the macro will replace any existing files of the same name in the new folder.

If you want to preserve earlier versions of those files, you should relocate them before playing this macro (or at least rename the next batch of files using the vName variable in the User Modification Area). By default, a "Yes/No" warning is given; this message can be enabled or disabled in the User Modification Area.

☐  There is another Messagebox() command that can pop up a message at each "splitting" point. It may be useful for new users that are not used to the operation of this macro. You can enable or disable this message with a variable in the User Modification Area.