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 May 3, 2018

MAKESUBS - Make subdocuments from multiple files

Download MAKESUBS.ZIP (v1.09; 11/16/2012; 22,017 bytes)

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


Some resources  -

For more information on creating master and subdocuments, see -

•  WordPerfect's online Help (F1 key, "Using master documents")

• 
Laura Acklen's Corel tutorial, "Working with Master Documents and Subdocuments".
•  "Notes and tips for Master documents and Subdocuments"
(in the next column-->
)

•  Formatting subdocuments can be more easily and reliably controlled with styles -- especially custom styles.

•  Problems? Need more help? Search (or join) WordPerfect Universe forums for peer-to-peer help with WordPerfect Office.

MakeSubDocs.wcm is a WordPerfect 9 (and later version) macro that inserts multiple files -- e.g., book chapters -- into the current (master) document as linked subdocuments.

When you play the macro, a menu (screen shot) appears with several options.

See Notes and Tips below for more information on using the Master/Subdocument feature. Some of that information comes from  expert users of various versions of WordPerfect, and over several years.

WordPerfect menu choices on this site refer to the <WordPerfect> menu (right-click on the top menu bar for a choice of menus). If you use a <Microsoft Word> menu, the choices might be absent from your menu (but not from the program), or they might be found under another menu selection. See here for more.



Before using MakeSubDocs.wcm for the first time...

Gather the files ("subdocuments") you want to include in the Master document in the same place.

Important:

•  Be sure to keep the Master document in a separate folder from all the subdocuments.  Reason: MakeSubsDoc.wcm will process ALL files found in that folder that have the specified filename extension (.wpd is the default extension). The Master document will most likely also have the same filename extension, so you'll want to keep it separate from the other files.

•  It's also a good idea to copy all the files you want to include as subdocuments into that separate folder before playing this macro. Copying the files, rather than moving them, will help ensure that you have a backed up version of them.

•  If you have an existing regular document you want to use as the source of various subdocuments, it can be split up by saving sections of it as separately named files (perhaps with similar names like Chapter 01.wpd, Chapter 02.wpd, etc.). You can do this manually (i.e., copy and paste) or with the help of a macro. See the Notes and Tips section below.

•  Using a Master document differs in several ways from using a long, single document for your project. And using Subdocuments (separate documents saved on your disk) also differs . For example they might need to have some formatting codes added to them so they will work properly in an expanded Master document. Both of these issues are discussed in the Notes and Tips section below -- and well worth reading (or at least scanning) before you use the Master/ Subdocument feature.
(=Important information about some Master/Subdocument format issues.)


 See how it works.

You may want to play this macro while inside a new, empty master document (see notes and tips below) and with a few sample subdocuments until you see how it works.

The order of appearance of subdocuments in the Master document.

The alphabetical order of appearance of the subdocuments in the resulting master document may be different than you expected due to the way (some versions of) Windows physically stores files in its folders.

Hence, you have a choice of "ascending" or "descending" order on the macro's menu (screen shot). Ascending alphabetical order is the default and works for the majority of users. Try each choice to see which works best for your particular setup.

 Modifications.

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. (Use Tools, Macro, Edit to modify the macro's code.)

 Messages.

The first time you play the macro or edit it, you might get a pop up warning message about the SortArray command being obsolete.

However, this command seems to work just fine (and is used in other macros in the Library and by other WordPerfect macro experts).

Just press "Continue Compilation" if you get this warning.

Explanation: The appearance of messages about obsolete macro commands depends on the version of WordPerfect, and in any case they appear only the first time you play the macro (or when the macro is edited/saved.) These warnings were implemented by Corel in WP9/sp4 and were removed in a subsequent version. But even though many commands have been named 'obsolete' by Corel since very early versions — probably with a view toward consistency and conservation of code overhead — most still work, and probably will work in versions to come. (If you want more technical information about FileFind, SortArray, etc., see the comment at the end of the macro.)

Be sure to review the Notes and tips in the next section below.


Notes and Tips for Master documents and Subdocuments
If you intend to use the MakeSubDocs macro to help you create a functioning master document be sure to see the "Before using MakeSubDocs.wcm..." section above.

Even if you don't use it the following tips about the WordPerfect master/subdocument feature might be helpful to you.

☼  Overview

•  A master document is an ordinary WordPerfect document created as a sort of "shell" or "container" with embedded links (seen in Reveal Codes as individual [Subdoc] codes) to specified external files on your disk (the subdocuments). (See the next tip on how to create the master document.)

•  When you expand the master (File, Document, Expand Master), WordPerfect displays the linked subdocuments in the master, producing one large file. The subdocuments are still on disk as separate files.

This linking behavior is a common source of confusion about where each subdocument's content actually exists.

Tips

▸  In an expanded master document you can search through it, make global format changes to it, etc., just as you can with any open document.

▸  Be sure to read the tips below on removing links from an expanded master document.  For example, if you remove all of them (easily done with Find and Replace) the result will be a single, normal document -- as though you had used Insert, File to join ("concatenate") all the (subdocument) files on disk into the open (master) document. It will no longer be linked to the external subdocument files. Remember to save the master file under a different name if you wish to preserve the original master/subdocument linked format.

•  When you condense and save the master document (with File, Document, Condense master) it will shrink back to displaying just the linking codes plus any separate material that you have added to the master document itself.
- The links are represented by a small icon at the left edge of the page:SubDoc link icon
    You can click on the icon to see the path and name of the linked document.
    In Draft view (View, Draft) you'll just see the path and name in a "box".
- The linking code in Reveal Codes are shown as [Subdoc].

•  You can also expand some subdocuments and condense and/or save others, so that you can work on just certain sections of your project more easily.

•  See the rest of the tips below -- especially about working simultaneously on a master document and one or more subdocuments.

☼  To create a master document (basic steps)

•  Decide on the type of document to use as the master document

You could use any regular WordPerfect document as a starting point for the master document, but it probably is best to start with a new blank document and then set up any introductory material in that master document.
[You might consider setting up the master document as a custom template.]

•  Use a separate folder for the subdocuments

For the purpose of using the MakeSubsDocs.wcm macro, you should place the files that you wish to use as subdocuments in their own folder, separate from other files and separate from the master document file. (As well, it's always a good idea to archive the originals in another location, just in case.)

Even if you create a functioning master document without the help of MakeSubDocs, it still is a good idea to keep all subdocuments together.

•  Want to use material in an existing document for your subdocuments?

If you have an existing document that you wish to break up and use the parts as subdocuments you can select portions of the document and use the Save (or Save As) buttons to create separate subdocuments. [Tip: The Splitter macro might help here since it can break up a file more or less automatically.]

•  Linking the subdocuments to the master document

You can link the subdocuments to the master document from inside the master either with

File, Document, Subdocument (to individually choose the files to include),
    - or with -
the MakeSubDocs macro (to quickly include all files found in the separate subdocument folder).

☼  Get a little practice

Although it's not "rocket science" there's a little bit of "beyond-newbie-user" information to learn here.

Start simple

It might even be a good idea to create a new, fairly simple master document with 2 or 3 sample subdocuments linked to it, and then play with them a bit to see how things work -- especially with some formatting issues, such as those discussed below.

Backups, backups!

Until you are comfortably familiar with the master and subdocument feature...

•  Make backups of the master document to another folder or drive.
Note especially that your master document contains full drive-and-path links to its subdocuments, so be careful not to accidentally open a back up copy of that master to use it -- or it might overwrite the original same-named subdocument files (to which it probably is still linked). In other words use backups to restore, not to use.

Renaming backup files to identify them in a consistent manner as archived backups is a good idea; they can always be renamed to their original names if they need to be moved into their original location to replace the "bad" file there.

•  Make multiple interim backups of subdocuments to another folder or drive (and in a different location from your master document backups). These are the most important parts of your master document. You could use a separate third-party program that can automatically make multiple backup versions of each changed file. See here for a few suggestions.

If you restore any of these backed up subdocuments be sure they are in the same path and have the same name as the originals to allow the [Subdoc] links in the master to work properly.

To see a [Subdoc] link's current path and filename: In the master, just place your cursor to the left side of a [Subdoc] code in Reveal Codes to view the currently designated path and name of the subdocument on the code itself. (If you delete the code you can re-link the master at that point to its subdocument with File, Document, Subdocument.)


Tip

Develop a habit to CONDENSE the master BEFORE saving or closing it.  Otherwise (and in addition to an issue of using unnecessary disk space) if your expanded master document might be saved later it could overwrite any previously (and separately) edited subdocuments that are linked to it. 

See the Corel Tutorial (next) for more on why to use this procedure.

See also "Condense subdocuments without saving them?" below.


[Thanks to Larry Lewis for several of these tips.]

☼  Read the Corel Tutorial

The Corel tutorial, "Working with Master Documents and Subdocuments" (which originally appeared way back in the March 2005 edition of the old Corel Newsletter -- but is still relevant) contains some valuable tips such as these relating to saving the master and subdocuments:

"... You should always condense a master document before you [close it or] 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 [with the Condense/Save Subdocuments dialog], 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 in separate WordPerfect windows], 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 [then] save the master document.
2. Make changes to the subdocument.
3. Save and close the subdocument.
4. Open and expand the master document. [That is, refresh the SubDoc links.]

The changes now appear in the expanded master document. At this point, you should generate the document (Tools, Reference, Generate) to update [any] index, table of contents, table of authorities, and so forth. ..." [Emphasis and annotations added.]

The tutorial also has information about formatting subdocuments. It's brief, but worth a read.

☼  Condense subdocuments without saving them?

Important:

Be especially aware that when condensing one or more subdocuments without saving them you merely hide them from view and any changes previously made to the subdocuments will not be saved at that time.

[Note: If you use File, Document, Condense Master, it brings up the Condense/Save Subdocuments dialog; this dialog is where you can choose the Subdocuments to condense and/or save by ticking or clearing their adjacent check boxes. The dialog's default setting is to condense and save all subdocuments.]

This is analagous to using an outline, where you can hide/expand various outline levels to help you focus on particular sections of the document. But it differs from an outline in that if you don't save subdocuments (in the Condense/Save Subdocuments dialog), the edits to the subdocuments are lost -- even if you save the master document.

While this might be what you want to do, you should know that changes in the subdocuments must be deliberately saved [i.e., check boxes ticked in the Condense/Save Subdocuments dialog] if you want to retain any changes -- just like any other open documents.

  Master document formatting codes will apply to subdocuments, except where codes of the same formatting type but with different settings are found in a subdocument

In WordPerfect, format codes take effect until replaced or discontinued. This is known as stream formatting (for more see here).

Since subdocument codes are "downstream" from the expanded master document, they can replace earlier versions with different settings (such as if they have a different line spacing from the line spacing code in the master). Conversely, "upstream" codes can affect material in later subdocuments, as explained below.

Moreover
, format codes can be stored inside styles (for more information see the Styles and Custom Styles pages) so be sure to check styles if they are "upstream" from a format problem (including the initial [Open Style: DocumentStyle] style code in documents). You can double-click on a [Style] code in Reveal Codes to examine the Contents pane.

Keep this "stream" model in mind when trying to solve format issues in documents. Also see the tip by Charles Rossiter below about forcing subdocument formatting to "stick."

  Codes missing?

If the same formatting code with the same settings exists in both the master and the subdocuments, it might be stripped out in subdocuments (WordPerfect will see it as redundant) when you condense and save the master: See Footnote 1. [Also see the next item about styles.]

  Master document styles will override any subdocument styles that have the same name (for more information on styles see the Styles and CustomStyles pages)

This includes the initial Open Style: DocumentStyle code that is found at the beginning of all documents. As Noal Mellott wrote on WordPerfect Universe:

"The codes in the master document's OpenStyle will override and overwrite all the [initial] OpenStyle [code]s in the subdocuments when the file is generated...."

Note that WordPerfect styles are like small containers, and a [Style] code can contain other styles as well as format codes, etc., so you should open them (double-click on the code) to see what they might contain when setting up or formatting a master document with subdocuments.

Thus, same-named styles can create problems -- but see the tip below for a solution.

For example, some formatting in the subdocuments can be replaced by similar formatting located in the master document's style(s), which is "upstream" from them.

Also, the entire contents of a "downstream" style's code can be replaced by the contents of a same-name style in the master, and will be saved with the subdocuments.

(Conversely, new styles with unique names created in subdocuments -- such as you might create with the following tip -- are saved with the master document. This can be handy if you add more subdocuments later and need to apply the unique style: they will be available to subdocuments because they will be "inherited" from the expanded master document.)

Tip: You can force subdocument formatting to "stick":

[From Charles Rossiter, Corel C_Tech:]

"[1.] 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.
[2.] Next, do Format, Styles, Create. Name the style [12 characters maximum].

[Ed. note:

Use a unique name for each such custom open style for your subdocuments.

For example, you could use _InitChapt for the chapters, _InitAppend for the appended materials, etc..

The Type of style should be set to "Document (open)" so it applies to the entire subdocument.

Note that by naming the style with a leading "_" the style will be at the top of the Select Styles drop-down list on the text property bar, making it easy and quick to select.]

[3.] Click in the style editor window [i.e., its Contents pane] and do Ctrl+V to [paste] your chosen formatting.
[4.] Save the style.

[Ed. note:

For more on creating and saving custom styles, including saving them to your default template or other template, see here.]


[5.] Then whenever you first [or next] open one of your [sub]documents, apply that [custom] style [at the top of that document].

[Ed. note:

Don't put the new custom style inside the initial [Open Style: DocumentStyle] code in the subdocument, for the reason given above. Just put it in the body text area, before all other text. This should also make it easier to find and modify if necessary.]


If you find you need to change that [custom] style, you can just edit it and it will automatically apply to all documents with that style."

  Certain subdocument styles can override master document styles -- the opposite of the previous item

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.

  Reference tools (Table of Contents, Table of Authorities, List, Index, Cross References)

As Laura Acklen says in The Complete Reference Guide [a book that's apparently no longer available] and in the Corel Tutorial referenced above,

"...You can mark text for [automatic inclusion in] a table of contents, table of authorities, list, index, or cross-reference in both the master document and subdocument.
...
If you're marking headings for a table, list, or index, you should consider creating a style for your headings with all the formatting and mark text codes [see here for how to do it for a table of contents or list].

...
Because expanding the master document compiles a list of all the marked [cross-reference] targets you might find it easier to mark targets in the expanded master document."

Tip:

You can have multiple Tables of Contents (see the TOC page for how to create a Table of Contents) using the Master/Subdocument feature. Some documents require a separate TOC for appendices, chapters, etc. This is most easily done by placing individual TOCs in the desired subdocuments and generating them there. The expanded Master can then have a complete TOC referencing all subdocuments, if desired.

  Footnotes and endnotes

As Laura Aklen says (same reference as above, but [annotated] here):

"Don't place footnore or endnote option codes in the subdocuments. These codes, which control spacing between footnotes, separator lines ... should only be placed in the master document.

[Important: See the next tip below about endnote placement and restarting endnote numbering in Master/Subdocuments.]
...
In most cases, footnotes should be numbered sequentially throughout a document. However, if you decide to restart the numbering in each subdocument, you need to place a footnote number set code in a [custom] open style at the top of each subdocument." [Emphasis added.]

[More on Laura's point about restarting footnote numbers in each subdocument with a style:]

The reason for putting the number (re-)set code inside a custom open style at the top of the subdocument is that t
he program will not accept a new beginning footnote numbering value that is the same as the default ("1") for a document. [Side note: Something similar happens with some other program features, such as forcing a page margin setting to the same value as the normal program default (see here).]

This differs from restarting endnote numbers since all endnotes in a document are actually inside a special (but editable) structure and not part of the normal document as far as numbering is concerned. Hence, when using a custom open style (which acts as a "container"), footnotes relating to that subdocument will accept a new number command (i.e., to start with "1"). In effect, the style's contents take precedence over the program default. See the next tip below for more on endnotes.

To manually create this new open style to restart footnote numbers (see also a macro to do this referenced in the related tips below):

•  Open a new blank document. (Preferred but not required.)
•  Use Format, Styles, Create. This opens the Styles Editor.
•  Name the style, such as "FN-restart" [12 characters maximum] and give it a description.

•  Change "Enter key inserts style" to "<None>".
•  Set the Type to "Document (Open)".
•  Click in the Contents pane to place the cursor there.
•  On the Styles Editor dialog's menu use Insert, Footnote, New Number and set it to "1". This inserts a [Footnote Num Set: 1] code in the Contents pane.
•  Click OK, OK to return to the Styles dialog; then click Insert, Close.
In Reveal Codes you should see an [Open Style: <stylename>] code. This style code contains the now-active footnote number set code.
•  You can select just that code in Reveal Codes, copy it (Ctrl+c) to the clipboard, and paste it (Ctrl+v) at the top of any subdocument (i.e., above the footnote numbers in the body text area).

-----

Related tips:
▸ For a macro to create the above custom style, and optionally insert it in the current document, see Footnote 4.
▸ For general information about creating, using, saving (e.g., to your template), and retrieving custom styles see here.
For other tasks, see also Charles Rossiter's basic method to create custom open styles above.

  Endnote placement and restarting numbering

Unlike footnotes (previous section above) which are placed on the bottom of the current page (and might continue to the next page), endnotes are automatically placed, and sequentially numbered, at the end of the document after all body text.

But when using master/subdocuments you have two choices.

You can place endnotes either
[1] at the end of the entire (expanded) master document, or you can place them [2] at the end of each subdocument's related text area (with or without restarting their numbers).*

Note: It is not a good idea to do both in the same project or you might confuse the program.

Methods:

[1] To place all sequentially numbered endnotes at the end of the master document just use File, Document, Expand Master.

The program does the placement and numbering (and any renumbering for additions or deletions) automatically ... but this assumes that no Endnote Placement codes (see next paragraph) exist in any of the subdocuments. If so, they should be removed first. (Find and Replace should be able to do it.)

The idea is to simply let the program treat the expanded master document as a single, continuous document and let it set up all the endnotes at the bottom of that document, continuously numbered.

    - or -

[2] For endnote placement at the end of each related subdocument when you expand the master document you will need to insert an Endnote Placement code at the very end (i.e., bottom) of the subdocuments. Again, this assumes that there are no Endnote Placement codes in the master document to cause a conflict.

•  Open each subdocument, navigate to the bottom after all body text and format codes.**

•  Choose
Insert, Footnote/Endnote on the WordPerfect menu.

•  Click the Endnote Placement button on that dialog.
Footnote/Endnote dialog

(If the button is grayed out and inactive, click the Endnote radio button first.
Even if there are no endnotes in the document, no harm is done by following this method.)

This opens the Endnote Placement dialog.
Endnote Placement dialog

•  Choose the first radio button,

    "Insert endnotes at insertion point"


and click OK to dismiss the dialog. (See a brief discussion about the second radio button in the next paragraphs below.)

•  Click Close on the Footnote/Endnote dialog to return to the document.

Discussion

At this point the endnote numbers in the subdocuments would be continuously numbered in the expanded master document. And if you later delete or add endnotes to the subdocument, the notes will re-number automatically. (Note: An extra blank page might appear at the end of the document, which can be deleted by deleting the [HPg] code there.)

While this continuous numbering scheme might be desirable, WordPerfect offers another choice
in the Endnote Placement dialog: 

    "Insert endnotes at insertion point and restart numbering"

This choice allows you to force the endnotes in the subdocuments (or just in certain subdocuments) to restart with the number "1" at the cursor location.

Important

In my opinion the "...restart numbering" choice in the Endnote Placement dialog is more useful in a long, regular document containing multiple sections with endnotes in each section (e.g., Chapters in a single-document book manuscript).

But iit should not be used in setting up subdocuments on disk to restart numbers when they are linked to a master document. In that case the choice can be problematic ...
at least this appears sometimes true in recent versions of WordPerfect.

HOWEVER
see Footnote 3 below for an easy, reliable method to restart each subdocument's endnote numbering in an expanded master document.

----------
* Endnotes can also be placed at the end of separate sections (e.g., chapters) in a regular document, not just in an expanded Master document. See here for some tips.

**
If the last body text in the subdocument is enclosed in a paragraph style, you may need to manually insert a hard page break (Ctrl+Enter) following the paragraph style's ending code before using this method. (Open Reveal Codes to ensure the cursor is properly located.)

☼  Removing subdocument links from a master document

Two scenarios:

[A] When you remove a subdocument link (shown in Reveal Codes as [Subdoc]) from a condensed master document, the subdocument file remains on disk as a separate file. You have simply broken the link to it from the master document.

[B] 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 the external (subdocument) file. Remember to save the master file under a different name as a backup if you wish to preserve the original master/subdocument with its linked format.

Related tip (for scenario [B]):

To quickly remove all subdocument links 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 also 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 if you wish to preserve the original master/subdocument linked format.

Related tips (to the one just above):

- For simply joining files: Some users have made use of this "remove-the-links" trick on a new, MakeSubs-created master document to concatenate (join) hundreds of WordPerfect disk files into a single file, rather than tediously using Insert, File on each one.

- For converting multiple WordPerfect files to a Microsoft Word document: A user reported that this technique of turning all WordPerfect subdocuments into ordinary parts of the current document is a good method to use before converting it into a single Microsoft Word document.


☼  Use View, Draft (on the main menu) in the master document to see the names and paths of the subdocuments

If you don't see the path and name, click Tools, Settings, Display, Document and enable "Margin Icons."

Related tip: Place all subdocuments in a folder whereby the path to that folder and any subdocument name will not exceed 55 characters. Otherwise, you may not see the filename.

☼  You can rearrange subdocuments in a master document

Cut and paste: In a condensed master document, select the desired [Subdoc] code in Reveal Codes, cut it to the clipboard with <Ctrl+X>, and insert it in the new location with <Ctrl+V>.

Note

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. This effectively moves the document's display in the master.

Tip

Automate the process: While you can manually cut and paste individual [Subdoc] codes in a master document to relocate them, or manually insert new [Subdoc] codes later,
here's a tip from Larry Lewis on WordPerfect Universe (here) that can help rearrange your preferred order of subdocuments as they should appear in the master document.

This also helps you keep the actual files organized on disk in the same "proper" order of appearance as in the master. It also helps you to quickly re-establish the master's links to the subdocuments even if you move all subdocuments to a different folder (thereby breaking the master's original links to them).

Example: Assume you just want to rearrange some (or all) of the subdocuments in the master.

[1] [Optional if not already done:] Create the master document's subdocument links -- i.e., insert the [Subdoc] codes using the MakeSubs macro (as above) or by manually inserting them.

[2] Expand the master document (as above).

[3] Make note of which subdocuments you want to re-order.

[4] Condense the master (see also the sections above about condensing).

[5] Navigate to the subdocuments folder and rename the subdocument files on disk with a leading number (or other string) as part of their filenames so that all of them will be sorted by name into the preferred order (see "the order of appearance" above).

[6] Open the existing master, delete all [Subdoc] codes in the master -- they are just links, as noted above -- and re-insert them again with MakeSubs (step [1]).

  Starting new pages

If you insert a hard page break (Ctrl+Enter) between each subdocument code in the master -or- at the top of each subdocument, you can force each of the subdocuments to begin on a new page.

  Consider setting up two custom templates for each type of project

Set up one for a master document and one for a subdocument. For more on custom templates see here.

  Turn on a warning message

One handy setting that can help eliminate the problem of accidentally deleting codes, especially when working with master/subdocuments: In Tools, Settings, Environment, Prompts (tab), enable "Confirm deletion of codes...."

☼  Backups

Make lots of backups when working with master and subdocuments. The MULTISAV macro, NewFN#.wcm, in the Library can help.

☼  Can a macro determine the state of a Master document (i.e., expanded or condensed)?

See Footnote 2 below.



Footnote 1

[Continued from above...]

From Using WordPerfect Office X3 by Laura Acklen and Read Gilgen (Que, 2006):

"Automatic Code Placement (the behind-the-scenes WordPerfect feature that positions certain codes for you) . . . can strip out redundant codes, resulting in a subdocument that can no longer stand on its own. For example, let's say you have a double-spaced master document. When you expand a subdocument with a double-spacing code in it, the Auto Line Formatter [a component of Code Placement] strips out that code, because it's redundant. When you save the subdocument, it is saved without the double-spacing code so it is saved as a single-spaced document. . . ."

So it appears that Charles Rossiter's tip (above) about creating a new, custom style for the top of all subdocuments is a practical solution that will force the formatting of those subdocuments, regardless of what happens in the master document. Your formatting should "stick." It's a simple method, too, and relies on the simple idea that if you set codes at the top of a document (or where they are needed) they will be available for the rest of that document (unless replaced or discontinued). Since styles
are like "containers," they are easily inserted where needed, even if they contain many format codes (and even text).



Footnote 2

[Continued from above...]

Can a macro determine the state of a Master document (i.e., expanded or condensed)?

There does not seem to be a direct way for a macro to determine the state -- i.e., whether it's a Master/Expanded document, a Master/Condensed document, or it's NOT a Master document.

However, [Subdoc] codes in the Master change depending on the state of the Master:

•  In a condensed Master document, you'll see single [Subdoc] codes for each subdocument linked to the Master. (The numeric value of the code is 2516.)

•  In an expanded Master document, you'll see paired codes: [Subdoc Begin] and [Subdoc End]. (Their numeric values are 3796 and 4052, respectively.)

Therefore, you could simply have a macro search for the existence of one or the other codes (either [Subdoc] or [Subdoc Begin]) to tell the macro which state the Master is in, condensed or expanded.

Here's a demonstration macro that should do the job. Modify the code to suit your needs.

To copy this code into your WordPerfect program to create a working macro see here.

// Macro code begins
// PURPOSE: Determine the state of the current document -
// Master/Expanded, Master/Condensed, or not a Master:
MatchSelection
OnNotFound(NoSubBegin@)
PosDocVeryTop
SearchString(NToC(64371)) // (<= [Subdoc Begin] code)

SearchNext
Messagebox(;;
   "Found a [Subdoc Begin] code: It's an expanded master document.")
SelectOff
Quit
Label(NoSubBegin@)
OnNotFound(NoSubdoc@)
PosDocVeryTop
SearchString(NToC(64366)) // (<= [Subdoc] code)

SearchNext
Messagebox(;;
   "Found a Subdoc code: It's a condensed master document.")
SelectOff
Quit
Label(NoSubdoc@)
Messagebox(;;
   "No Subdoc Begin or Subdoc codes found: It's not a master document.")
SelectOff
Quit
// Macro code ends



Footnote 3

[Continued from above...]

Endnote placement in subdocuments -- especially when restarting endnote numbering to "1" in each (or any specific) subdocument -- can sometimes be problematic.

As noted above, one issue is to avoid trying to place endnotes in specific locations and/or reset their numbering inside an expanded master document. This can sometimes confuse the program when using the Master/Subdocument feature.

Another issue is how to reliably cause the endnote numbers in an expanded master document to be displayed at the end of each subdocument material and have their numbers start with "1" for each of the displayed blocks of endnotes.

The best way I have found to do this is to [1] first add the endnote numbering reset code in the subdocument and then [2] add the endnote placement code -- both at the very end of that subdocument after all other text and format codes.

Manually, here's how you can do this in the subdocument:

Step 1

•  Open Reveal Codes.

•  Position the cursor at the very bottom of the document after all body text and codes. [In Reveal Codes you will see nothing to the right of the Reveal Codes cursor ... just blank space. (If the last body text is enclosed in a paragraph style, you may need to manually insert a hard page break (Ctrl+Enter) following the paragraph style's ending code before using this method. Any such extra page can be deleted later.)

•  Use Insert, Footnote/Endnote and be sure the Endnote radio button is enabled.

Then click the Options button, then "Set number".

In the next (Endnote Number) dialog, set the new number to "1" (3rd radio button field).
 
•  Click OK, and then Close (NOT Create) on the Footnote/Endnote dialog.

This inserts a [Endnote Num Set] code at the cursor location in the document.

Step 2

•  Use Insert, Footnote/Endnote and be sure the Endnote radio button is enabled.

•  Click the Endnote Placement button. The Endnote Placement dialog appears. Ensure the "Insert endnotes at insertion point" (1st radio button) is selected.

•  Click OK and then Close (NOT Create) on the Footnote/Endnote dialog.

This inserts a [Endnote Placement] code (and typically a [HPg] code which can be deleted to remove any unwanted blank page).

Both codes should look like this (and in this specific order) in Reveal Codes:

    [Endnote Num Set][Endnote Placement]


----------
Tips

Alternatively, you can use a macro to instantly insert both codes in the proper sequence at the bottom of the subdocument (open separately for editing), and also remove any [HPg] code:


// Macro code begins

/ PURPOSE: Adds Endnote renumbering ("1") and Endnote placement
// codes to a document at the very bottom after all other material.
//
// First, go to the very end of the document:
PosDocBottom
PosLineVeryEnd

// If Endnote Number code (2264) or Placement code (5587)
// exists to the left of the cursor, delete it:
While(?LeftCode={2264;5587}) DeleteCharPrevious Endwhile

// Insert the required codes:
EndnoteNewNumber (EndnoteNumber: 1)
EndnotePlacement (Restart: No!)

// Delete any hard page code on the left:
If(?LeftCode=199)  DeleteCharPrevious  Endif

Quit

// Macro code ends


To copy this code into your WordPerfect program to create a working macro see here.

Subsequently, when the subdocuments are opened individually from the disk (like any other document) any endnotes in them will appear -- as expected -- at the bottom of the document and start their numbers with "1". The presence of the endnote number and endnote placement codes will not interfere with the program's internal instructions to do the same thing.

But when such subdocuments are linked to a master document (as discussed above on this web page), and when the master is then expanded, the codes -- being "downstream" from the body text of the subdocument -- will [1] restart numbering and [2] display the endnotes at the end of each subdocument that contains endnotes.

If you don't want the numbering reset for any particular subdocument -- i.e., you want the numbers to continue in sequence from the end of the previous document -- just open that subdocument and delete the endnote numbering code. (But retain the endnote placement code.)


Footnote 4

[Continued from
above...]

To restart footnote numbers to "1" in a subdocument quickly and easily with a custom style so that the relevant restart code is active in that document -- and more importantly, in an (expanded) master document linked to that subdocument -- you can use a macro.

The following code creates a custom Document (Open) style named _FN-Restart in the open document and also inserts it.

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

[The leading underscore helps the style appear at or near the top of your styles list. The name is not critical and can be modified on the vStyleName command line surrounded by double quote marks. For more on custom styles see here.]

Note that if a style
by that name already exists in the document being edited, the macro will not create it again. The code simply skips down to the OPTIONAL segment.

In the OPTIONAL segment the macro inserts (i.e., positions) the custom style at the top of the document when you play the macro.

[The OPTIONAL segment's PosDocTop command can be deleted so that the macro can also be used in other documents where restarting at various specific locations (e.g., chapter sections) might be more desirable. In that case, the style would be inserted at the current cursor location. The StyleON() command could also be deleted, which results in simply adding the custom style to the current document, where it will be stored with the document and be available from the property bar's Styles list as needed.]

Tip: To copy this code into your WordPerfect program to create a working macro see here.

// Macro begins here
// PURPOSE: Create a custom Document ("open") style.

// Set your style name and description here
// (between the double quote marks):
vStyleName:="_FN-Restart"
vStyleDescription:="Restarts footnote numbers"

// If the named style already exists, OnError() skips this segment:
OnError(SkipCreateStyle@)
// Next, open the Styles Editor and create the basic style
// (all Style commands should be on separate lines):
StyleCreate (Name: vStyleName; Type:OpenStyle!; Library:CurrentDoc!)
StyleEditBegin (Style: vStyleName; Library: CurrentDoc!)
StyleDescription (Description: vStyleDescription)
StyleEnterKeySetting (Action: StyleOff!)
StyleCodes (State: WithOffCodes!; Library: CurrentDoc!)

// Restart footnote numbers to "1":
FootnoteNewNumber (FootnoteNumber: 1)

// Exit from the Styles Editor:
SubstructureExit ()
StyleEditEnd (State: Save!)

// If style already exists, jump down to here:
Label(SkipCreateStyle@)

// OPTIONAL: Insert the style in the document:
PosDocTop
StyleOn(vStyleName)

// Exit macro here:
Return
// Macro code ends here