Training > Tutorials > Microsoft Word > Compiling Sub Docs
Compiling Sub Docs
This article explains how to use the RD field codes to compile large, complex documents.
Manual Master Docs
Many Word users need to compile documents such as books or manuals. But, unfortunately, many users who give the Master Document feature a shot, experience problems with memory errors or mysterious too many files open errors. But you can still save your project by doing a little manual Field coding.
When a book or manual project is dumped on your desk, you can try to squeeze all the text into one document. But chances are that you'll end up with too many pages or too many links and memory errors will stall your project. You can also try using the Master Document feature in Word, but unless your project is small, you'll probably still receive errors.
A better way to go about this is to just write your chapters as individual files. Try to keep the size of each chapter under 50 pages. If you need to add links for other text files, bookmarked portions of other files, or graphic images, try to use linking rather than embedding. This will not save the linked files within the actual documents. Therefore, the size of the files will be smaller.
However, because outside information is only linked to the document, if you need to move any of the documents or linked source files, you'll have to then also modify all the links or they'll be broken. If you prefer to keep your graphics within the actual sub documents, you should keep the number of total pages per sub doc down.
If you do end up breaking the links, see the Field Link Converter article mention along the side panel. This article contains a macro to help you more easily fix all the broken links.
If you do link your graphics, you may have difficulty dealing with text moving around between what's on your screen and what you actually print out. You would use the Insert/Field/INCLUDETEXT or Insert/Field/INCLUDEPICTURE to link other files into your main sub docs.
Since these are Field codes, you have the option to turn them on/off by either setting options in Tools/Options/View or you can just press Shift/F9 to toggle between fields and their results. However, you may then find yourself switching to code view, often, to help increase the screen redraw and scrolling speed in your sub docs. This is time consuming.
A better way to maintain the graphic locations within your files, yet keep the pictures from constantly redrawing, is to use the Picture Placeholder feature under Tools/Options/View. This will place an empty frame where your image should be so you can see where your picture belongs, in its correct size, without waiting for the screen to pull up the picture as you scroll through your doc. This will also help you avoid larger docs from crashing.
Pulling the Sections Together
Okay, so now your sub docs are all set up. But how do you pull these separate documents together in order to print out a Table of Contents or an Index? You'll use the RD (reference document) field code.
Create a new document from your master template—the one you should have been using to create the original sub docs—to keep the pages looking consistent. Where the TOC should begin, click Insert/Field/RD. In the input line for the RD code, you'll need to type in the name of each sub doc file that you want referenced.
Your code will look like this:
Note! The learn more about this and other field codes, you can click Insert/Field Code. A dialog will appear. Click once to highlight the field code you're interested in, and then click the question mark icon in the upper/right of that dialog. This is your Help icon. Now click once, again, on the same highlighted field code. This will open the help information for this field. There you can read all the details for using the code you highlighted.
Remember that you need to enter the names of all the sub docs in the order you want them referenced. In other words, if the first doc is Chapter01, then Chapter02 and so on, enter them in that same order, or your TOC will be out of order.
Also note that you don't need to enter the full path if you are keeping the sub docs in the same directory as the new file you create for the TOC or Index. However, if you have them in a separate directory, you'll need to enter the full path.
Important! When you need to enter paths in a field code, you must use double backslashes to represent paths. This is because switches use single backslashes. The double backslashes help Word understand that this information represents path information. And if the directory paths or file names have spaces in them, you must wrap the path/file information in double quotes. This syntax information is contained in the field help files. But the sample below will show you the proper way to enter these path/file names.
Once you have assembled an RD code for each sub doc, you now need to add the appropriate TOC or Index code. Click Insert/Index And Tables. Choose the tab for the item you're going to create. There are many available options to design your format. If you're creating a TOC, you'll also have to supply the names of the styles you used for each heading/sub heading. If you're not sure what these options mean, check the Help files for complete details.
Now you just need to pull it all together. Press CTRL/A to select all the text. Press F9 to update the field. You may also have to press Shift/F9 to toggle off the field code and see the results. Voila!
You can save this as your TOC/Index. If you make changes and need an updated version, just select the code and update it again with the F9 and/or Shift/F9 keys.
Before you finalize your document, make sure you open each document in order and check the last page number. Then open the next document and reset the starting page number to the next number.
Note! There is a complex process you can use to have your documents automatically calculate and set your page numbers. It's somewhat complex and I won't be explaining it in detail here. However, I do teach you how to do this in my Advanced Document Design course.
Briefly, you need to set a page reference to itself on the last page of each sub doc, using the PAGEREF field code. This will cause the current page number to be displayed. Select this field result and wrap it in a bookmark. While still selected, set the text to hidden. This will prevent this renegade number from being displayed in this document.
Now move to the next document. If you just need to reference this page number, use the INCLUDETEXT field to pull the hidden number into your new document. However, if you need to use this number and increment it up one to represent the next page number, you'll need to do some tricky field nesting.
Use the INCLUDETEXT field and reference the bookmark name you used to wrap the hidden page reference in the previous document. Then you'll use the PAGE field to reference the current page in this document. These are both wrapped inside the SUM field.
The code works like this:
As I said, it's complicated. In my Doc Design course I provide further details and illustrations on this and other tips and tricks for assembling books/manuals in Word.
Tip! If you are assembling many doc files for your TOC or Index, realize that even though these codes are hidden, they are still taking up space at the top of your TOC/Index document. Since the text size of these codes don't matter, you can highlight the codes themselves and change the font size down to something very small. This will make them take up less space.
Also, you don't need to put each code on a single line. Therefore, more space can be saved by jamming them all up, one after another, on a single line. Just make sure you keep them in the order you need. Tiny code text will help ensure that you don't end up with a large amount of mystery white space at the top of your TOC/Index.