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

Page updated Oct 27, 2022

MAKESUBS - Make subdocuments from multiple files

Download MAKESUBS.ZIP (v1.10; 09/06/2020; 21,999 bytes)

Compatible with WordPerfect 9 (c. 1999) 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 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 macro that inserts multiple files — e.g., book chapters — into the current (master) document as linked subdocuments.

A master document containing (links to) multiple subdocuments can help manage large documents (e.g., book manuscripts) during editing, or simply let you combine many separate documents into one.


Note

◄— See "Some resources" in the left column for more on the main purpose and use of Master documents and Subdocuments.

On the other hand, the material on this page deals with a macro you can use to help you create a master with its linked subdocuments. It has many tips related to these documents — but it does not give much basic information about them, so be sure to visit the resources linked in the left column (especially Laura Acklen's tutorial on the subject).

■  When you play the macro, a menu appears with several options.

MakeSubs menu

■  Before using the macro please read over the following sections for more information about using the macro and some tips on using the Master/Subdocument feature.

NOTE: 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 ... but in a different folder from the Master.

Important points

•  Be sure to keep the master document in a separate folder away from all its  related subdocuments.

Reason: MakeSubsDoc.wcm will process ALL files found in the specified folder (selected in the first field on the macro's menu) that have the specified filename extension (.wpd is the default). 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 specified folder before playing the MakeSubDocs macro.

Reason: 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 new 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.).

Methods: You can do this manually — i.e., copy and paste (or select and then Save) each of the various sections into separate files on disk. Or you can do it with the help of a macro that can split the source document into various subdocuments. 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 when they are expanded in the master document.

More information: 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.

• 
Caution

The MakeSubDocs macro is designed to be typically used just once in a master document — i.e., a document that has not previously been the subject of the macro's operation. (There are exceptions, discussed next.)

This is important because playing the MakeSubDocs macro in the same master document more than once will not remove or refresh any previous master/subdocument linking codes — mainly because some of them might have been previously inserted using subdocuments in various other folder locations. (For more on these Subdoc codes see the sections below.) This can lead to duplicate subdocuments in the master, possible confusion, or even "nested" subdocuments with related document formatting problems.

However, additional subdocuments — stored in a different folder from the one used in a previous operation — can also be separately inserted with the macro, generally starting on a new page at the bottom of the master document, away from other text or codes. (The cursor location in the master determines the starting point of the insertion.)

Remember: A macro simply does what you can do manually (but much faster). Here it inserts the necessary WordPerfect linking codes in the master that will link it to all specified subdocument files on your disk. However, automation like this needs to be employed with a basic understanding of the purpose and operation of the automation.

If you later want to add more subdocuments into a master document, you can either -

[A] manually insert (individually) the new subdocument linking codes from the WordPerfect menu (more on this below); or

[B]
store the additional subdocuments in a different folder from the previous one(s), then place the cursor at the bottom of the master on a new empty page and play the macro ("pointing" it to the new folder); or

[C]
create a new master and then play the macro in that new master with all subdocuments (both old and new) located in the same folder — but (as noted) separate from the folder containing the master.


•  The
indicates 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 in some WordPerfeect versions you might get a pop up warning message about the SortArray command being obsolete.

However, that 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 (above) to help you create a functioning master document be sure to see the "Before using MakeSubDocs.wcm..." section above.

¤  A basic introduction to the Master and Subdocument feature can be found in a Corel Tutorial here (which is also referenced below). It describes creating subdocuments, inserting them in a master document, expanding and condensing the master, and some tips on formatting the subdocuments. The notes and tips below contain some of the same material but also expand on these topics based on feedback from expert users.

¤  Even if you don't use MakeSubDocs macro 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 (with File, Document, Expand Master) a dialog  appears to let you choose the subdocuments to expand (shown are 3 sample subdocuments in a temporary folder, all of them chosen by default):

Expand Master Document dialog

WordPerfect then 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 on your computer.

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 your (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) a dialog appears to let you choose the subdocuments to condense (or condense and save; shown are the same 3 sample subdocuments, all of them chosen by default; note also its Mark/Clear button):

Condense Master Document dialog

WordPerfect then shrinks the chosen items back to just displaying their linking codes -- plus any separate material that you have added to the master document itself. The subdocuments are still on disk as separate files.

More tips

[For these to work you need to have enabled the "Margin icons" checkbox in Tools, Settings, Display, Document (tab).]

▸  The links are represented by a small icon (on 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. The linking codes in Reveal Codes are shown as [Subdoc].

▸  When the master document is condensed:

If you switch to Draft mode (View, Draft) in a condensed master the links are displayed in a manner similar to non-printable WordPerfect comments (Insert, Comment). But here, they simply show the full path and filename of each of the subdocuments on disk, which might be useful to you.

▸  When the master document is expanded:

If Draft mode is enabled in an expanded master, you should now see the [Subdoc Begin] and [Subdoc End] codes displayed with the full path and filenames displayed at the top and bottom of each subdocument.

Perhaps this expanded-master method will help you more completely identify all subdocuments in the expanded Master — if only on-screen, since the displayed [Subdoc...] codes do not print.

•  You can also expand some subdocuments and condense (or condense and 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.)

Tip

Keep the full path name to that folder, including each subdocument filename, relatively short (55 characters or fewer). While not strictly necessary, this can make them easier to identify later in the master document's Draft view or in the Reveal Codes window. See the related tip below. [Note that this is a harmless side effect of using a macro to insert subdocuments. Manually inserting them with File, Document, Subdocument will usually show the entire path and filename.]


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

Tip

Sometimes working on a document for a period of time can introduce minor (or major) internal corruption, especially to its formatting. (Lots of copy-and-paste operations in a formatted document are a frequent cause of this.) Even if you can open the document and it seems okay, it could still harbor some problems.

Hence it can be a good idea to first make a backup of the document, then run it through Corel's free, standalone file repair utility (named WPLook.exe) before linking it to a Master document or doing any global formatting of the Master. See more about it — and some other file repair methods — here.


•  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 with either -

[A] File, Document, Subdocument (the standard, manual method to individually choose the files to include)

    - or

[B] the MakeSubDocs macro (an automated method to quickly include all files found in the separate subdocument folder).

Once linked, the content of the subdocuments can be displayed in the master for further editing by expanding the master.

  Get a little practice

Although it's not "rocket science" there's a little bit of "beyond-newbie-level" 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 — 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.)

Tips

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 today) 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.]

***

Another thing to consider is whether you really want to save any edits to the subdocument(s). From the Corel tutorial:

"... You must carefully consider which subdocuments should be saved, especially if the subdocument belongs to a colleague. To save your changes without overwriting the original file, move or copy the original file before you condense and save the subdocument."

It's probably a good idea to back up the folder containing all your subdocuments before there's any chance you might want to edit them while using the Master/Subdocument feature
or while using any other editing method. [Tip: Many separate (third party) backup programs let you specify folders to back up, either on demand or on a schedule. Some can even do versioning, which saves multiple iterations of each file.]

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 (or condense and save) by ticking or clearing their adjacent check boxes (see also the Mark/Clear button on the dialog). 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.

Put another way: When you condense and save a subdocument, it would be the same as if you had that document open in another WordPerfect window (i.e., when not using the master/subdocument feature), and saved/closed it. Saved is saved, no matter how you do it.

  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 (expanded) 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".

(This tip applies to formatting that you want to apply to the entire subdocument (i.e., with "open" styles), to help prevent previous document ("open") formatting in other subdocuments from interfering with the current (and any following) one, when the master document is expanded.) 

[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. tips:

Use a unique name for each custom open style you want to use for your various types/purposes of subdocuments. This will help identify them when adding or editing subdocuments where they should be applied.

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.

If you name the style with (e.g.) 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 Styles 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:

Do NOT 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 (i.e., above) all other text. This should also make it easier to find later, and modify if necessary.]

[Finally:] 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."

Related tip for other types of normal documents — not subdocuments — gathered together nto a single document

This method can also be used wherever several documents are added/inserted directly (perhaps with Insert, File) into a single "normal" document (i.e., not as subdocuments in a master document) — especially if some of them differ in their "open" formatting (e.g., different default document fonts) and you want each to retain its document-specific formatting.

The inserted documents would have the same type of custom [Style] codes at the top of each document like those used in the subdocuments referred to in the above method. The codes will force each inserted document to retain the specific open style formatting that existed prior to its insertion.

But note that every such inserted document probably should have such a custom style at the top of the document to guide that document's open style formatting. Otherwise, documents inserted downstream could inherit possibly unwanted formatting from an upstream document.


  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 Acklen 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

  Scenario A

When you remove a subdocument link from a condensed master document — i.e., the link shown in Reveal Codes as [Subdoc] on the left edge of the page the subdocument file remains on disk as a separate file. You have simply broken the link to it from the master document.

Remember to save the (link-removed) master document under a different name if you wish to preserve the original master document with its linked subdocument format.

Tip (for Scenario A):

To quickly remove all subdocument links from a condensed master document:

[1] Place the cursor at the very top of the condensed master.
 
[2] Click Edit, Find and Replace. Place the cursor in the "Find:" field, and click Match, Codes.

[3] Scroll down in the Codes dialog to "Subdoc" (not "Subdoc Begin" or "Subdoc End") and select it, then click Insert & Close.

[4] The "Replace with:" field should contain "<Nothing>" or be completely empty.

[5] Click Replace All.

The document should now be an ordinary WordPerfect document, not a Master document.

Again: Remember to save the (link-removed) master document under a different name if you wish to preserve the original master document with its linked subdocument format.

  Scenario B

When you remove a subdocument link from an expanded master document i.e., the link at the top of each displayed subdocument's material shown in Reveal Codes as [Subdoc Begin] on the left edge of the page the subdocument file's material reverts to normal WordPerfect text inside the master document, just as though you had inserted that file into the master document with Insert, File. It will no longer be just a linked display of the external subdocument file's contents. As with Scenario A, the subdocument itself remains on disk as a separate file. (See the tips below.)

Remember to save the (link-removed) master document under a different name if you wish to preserve the original master document with its linked subdocument format.

Tips (for Scenario B):

To quickly remove all subdocument links from an expanded master document:

[1] Place the cursor at the very top of the expanded master.
 
[2] Click Edit, Find and Replace. Place the cursor in the "Find:" field, and click Match, Codes.

[3] Scroll down in the Codes dialog to "Subdoc Begin" (not "Subdoc") and select it, then click Insert & Close.

[4] The "Replace with:" field should contain "<Nothing>" or be completely empty.

[5] Click Replace All.

Since the "Subdoc Begin" code is part of an On/Off code pair (i.e., [Subdoc Begin]...[Subdoc End]), removing the first part of the code 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.

Again: Remember to save the (link-removed) master document under a different name if you wish to preserve the original master document with its linked subdocument format.

More tips (for Scenario B):

Quickly join many files into one file:

Some users have employed the "remove-the-links" trick above 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.

You probably will want each file separated by a hard page break inside the master document. You can do this when using MakeSubs.wcm to link each subdocument using the Add a page break option on the macro's menu. (Unwanted extra hard page break codes [HPg] can always be searched and replaced later with Edit, Find and Replace in the same way you removed [Subdoc Begin] codes above.)

Be sure to read the several tips above about the possible interaction between formatting in the master and its  subdocuments (and vice versa) that can affect the resulting formatting in the newly concatenated document.

When converting multiple WordPerfect files to a single 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 when using the MakeSubDocs macro [as explained above]:

Place all subdocuments in a folder whereby the path to that folder ("C:\..<folder>" — if it is on drive C) plus the subdocument's file name will not exceed 55 characters. Otherwise, you may not see the complete filename.
[Note that this is a harmless side effect of using a macro to insert subdocuments. Manually inserting them with File, Document, Subdocument will usually show the entire path and filename.]

  You can rearrange subdocuments in a master document (or reestablish links in the master to its subdocuments if you move them to another location on your system)

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 links in the master 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.

[Step 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.

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

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

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

[Step 5] Navigate to the subdocuments folder and rename the subdocument files on disk with a leading number (or other text 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).

[Step 6] Open the existing master document, delete all [Subdoc] codes in the master — they are just links, as noted above — and re-insert them again with the MakeSubs macro (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 subdocumentsespecially 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 codeboth 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