"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 Jun 27, 2008
MAKESUBS - Make subdocuments from multiple files

Download MAKESUBS.ZIP (v1.08; 01/11/08; 22,533 bytes)

Compatible with WordPerfect 9-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.

A WordPerfect 9+ macro that inserts multiple files (e.g., book chapters) into the current (master) document as subdocuments.

  • For more information on creating master and subdocuments, see WordPerfect's online Help (F1 key, "Using master documents").
  • Laura Acklen wrote a tutorial, "Working with Master Documents and Subdocuments," for the Corel Newsletter (March 2005 edition).
  • Also helpful is the section, "Working with Master Documents and Subdocuments," in Special Edition - Using WordPerfet 12 by Laura Acklen and Read Gilgen (QUE Publishing). It also has a dozen or more formatting tips.

Important notes on using MAKESUBS:

  • The first time you play the macro or edit it, you will probably get a warning message about the SortArray command being obsolete. However, this command seems to work just fine. Just press "Continue Compilation" if you get this warning.
    • (Warnings about obsolete commands were implemented by Corel in WP9/sp4. But even though many commands have been named 'obsolete' by Corel since very early WP versions — probably with a view toward consistency and conservation of code overhead — most still work, and probably will work in versions to come.)
  • You should first ensure that the files you want to include as subdocuments are all in the same folder on your disk. This macro will process ALL files found in that folder with the specified filename extension.
  • You may want to play this macro while inside a new, empty master document first until you see how it works.
  • You may want to modify the default values displayed on the macro's menu. You can change them in the redlined User Modification Area of the macro's code.
  • The order of files in the source directory/folder may be different than expected due to the way Windows stores files. Hence, you have a choice of "ascending" or "descending" order on the menu. Try each to see which works best for your particular setup, and set the default menu choice below. (If you want more technical information, see the comment at the end of this macro about FileFind, SortArray, etc.)

Tips for Master/Subdocuments:

  • Note that a master document contains links (shown in Reveal Codes as [Subdoc]) to the files on disk (the subdocuments). When the master is expanded with File, Document, Expand Master, WordPerfect displays the subdocuments in the master. They are still on disk as separate files. This linking behavior is a common source of confusion. (See related tips below, especially about working simultaneously on a master document and one or more subdocuments.)
  • Until you are comfortably familiar with the master and subdocument feature, make extra backups. You don't want to trash your first novel!
  • See the Corel tutorial, "Working with Master Documents and Subdocuments," in the Corel Newsletter (March 2005 edition). It also contains some valuable tips, such as these:
    • "... You should always condense a master document before you save it. Otherwise, you save the same information twice [in the expanded master and in the subdocuments] and consume twice the disk space. Because you've already saved the subdocuments, you don't need to save that same information in the master document.
    • If you are working in both master documents and subdocuments [i.e., the master and one or more subdocuments are open simultaneously], you may run into a situation whereby changes that you have made to a subdocument and saved do not show up in the expanded master document. These changes will appear in the master document only if you follow this procedure:
      • 1. Condense and save the master document.
        2. Make changes to the subdocument.
        3. Save and close the subdocument.
        4. Open and expand the master document. [I.e., refresh the links.]
      • The changes now appear in the expanded master document. At this point, you should generate the document to update the index, table of contents, table of authorities, and so forth. ..."
  • Master document formatting codes apply to subdocuments, except where different codes are found in a subdocument.
  • Master document styles usually override subdocument styles.
    • This can create a problem: Some formatting in the subdocuments of a master document can be replaced by similar formatting in the master document's style(s). However, you can force formatting to "stick" in subdocuments. From a tip by Charles Rossiter, Corel C_Tech:
    • "At the top of a sub-document, set up your formatting as you wish. Now select all the codes (and text, if any) that make up that formatting, and do Ctrl+C to copy to the Windows clipboard.
    • Next do Format, Styles, Create. Name the style. Click in the style editor window and do Ctrl+V to copy your chosen formatting. Save the style.
    • Then whenever you first open one of your [sub]documents, apply that style. Note that by naming the style [with a leading "_"] the style will be at the top of the style drop-down list, making it easy and quick to select.
    • If you find you need to change that default style, you can just edit it and it will automatically apply to all documents with that style."
  • Sometimes, subdocument styles override master document styles.
    • For example, if you used an outline style in one or more subdocuments, and you expect the outline to increment continuously throughout the entire (expanded) document (and not start at "1" in each subdocument), the [Outline] code that is inserted at the beginning of each outline can override the normal (sequential) order of outline items. Each [Outline] code contains a "definition" -- including numbering, where to begin, etc.
    • Solution: Expand the master document and find the first [Outline] code. Then delete all [Outline] codes after that one, in each of the included subdocuments that follow this first code. By deleting all but the first [Outline] code, the outline should be continuous through the master document.
  • When you remove a subdocument link (shown in Reveal Codes as [Subdoc]) from an condensed master document, the subdocument file remains on disc as a separate file. You have simply broken the link to it from the master document.
  • When you remove a subdocument link (shown in Reveal Codes as [Subdoc]) from an expanded master document, the subdocument file reverts to normal WordPerfect text inside the master document -- just as though you had inserted the file into the master document with Insert, File. It will no longer be a link to an external (subdocument) file. Remember to save the file under a different name to preserve the original master/subdocument format.
    • [Related tip:] If you use MakeSubs.wcm to insert multiple files and then want to turn all the files into ordinary parts of the current document, simply place the cursor at the very top of the expanded master document and then
      • Click Edit, Find and Replace. Place the cursor in the Find field, and click Match, Codes.
      • Scroll down in the Codes dialog to "Subdoc Begin" and select it, then click Insert & Close.
      • Click Replace All. Since the Subdoc Begin code is part of an On/Off code pair, removing the first part of the pair removes the second part.
      • The document should now be an ordinary WordPerfect document, not a Master document. You might need to do some reformatting of the newly included sections.
      • Remember to save the file under a different name to preserve the original master/subdocument format.
  • Use Draft view in the master document to see the names and paths of the subdocuments.
  • You can rearrange subdocuments in a condensed master document by selecting the desired [Subdoc] code in Reveal Codes, cutting it to the clipboard with <Ctrl+X>, and inserting it in the new location with <Ctrl+V>. If the master document is not condensed, select everything (for that subdocument) from the [Subdoc Begin] code to the [Subdoc End] code, including both of these codes, and cut/paste the material to the new location in the master document.
  • If you want to ensure that formatting in subdocuments is maintained (i.e., not changed by master document formatting), hide the codes (e.g., Delay codes, line spacing codes) inside each subdocument's DocumentStyle code. Here's how:
    • Open each subdocument as a separate file, before you combine them into a master document. In each subdocument, open Reveal Codes and select just the new code(s) to hide, then cut it(them) to the clipboard with <Ctrl+X>. Then double-click the initial [Open Style: DocumentStyle] code at the top of the subdocument; this opens the Style Editor; paste the code(s) into the Contents field, then click OK. (Just remember to look inside the initial style code if you need to revise or delete the code(s)!)
  • Make lots of backups when working with master and subdocuments. The MULTISAV macro, NewFN#.wcm, in the Library can help.

Programmers: If you want to use the FileFind() code in this macro to process files in some other way than is done here (say, to convert them, rename them, etc.), see the comments following the end of the macro code.