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 Jul 30, 2015

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

Download SPLITTER.ZIP (v1.0; 05/28/10; 14,373 bytes)

Written in WordPerfect X5 but should be compatible with earlier 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

This macro will split the current document into several new (and incrementally numbered) files on disk, such as:

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

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

(Note that if the numbered filename already exists in that storage folder, it will be overwritten. 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 size, beginning number, etc. (see below).

This macro might be useful as well 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 MakeSubs]

[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 download file, 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 "SEPARATORS" IN 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. Use the exact same symbol(s) as separators throughout the document.

• 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 file on disk (not on screen). 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. The current file is not affected by the splitting process and if it is a copy of the original it can be discarded.

• Here, the default separator expected by the downloaded macro is a single heart symbol (i.e., symbol 5,0), but you can use any other symbol or symbols. (See also #4 below.)

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

Modify the macro. (A WordPerfect macro can be opened and saved like any other document.) Normally, this is a one-time procedure, and is easy to do.

2. Create a special storage folder on your computer to store the new files. Use Windows Computer or Explorer to create the new folder in any convenient location. It can be named anything, but generally you will want to use a fairly 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. Enter the same symbol(s) or character(s) (discussed in #1 above) in the macro's redlined 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).

5. Set any other macro options in the redlined User Modification Area.

Play the macro on any open file that has the appropriate separators (#1 above) in it. 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. The new files should then be edited to make sure they contain the proper text, formatting, etc. Changes in formatting are usually the result of placing the separator in the wrong location in the original document. Use Reveal Codes to relocate any such separators.

  • By design, the macro will overwrite 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 macro's redlined 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.