Hack 78 Cross-Reference Among DocumentsThis hack shows you how to create cross-references among different Word documents. When you create a cross-reference in Word, no option exists for referencing content in another document. But sometimes you need to split your work into multiple files, like the chapters in a book. (Word once actually encouraged this practice; the Word 2.0 manual says, "If your document is longer than 20 pages, consider creating several smaller documents.") If you use fields and bookmarks, you can create your own dynamic cross-references among separate Word documents. A cross-reference has two parts: the reference and the target. A target is sort of like an Internet URL, and a reference is like a link to that URL. Each target can have multiple references pointing to it, but each reference can point to only one target. Just like URLs, each target must have a unique identifier. 8.10.1 Understanding Word's Native Cross-Referencing
When you make a cross-reference
in Word
(Insert Figure 8-17. Word's Cross-reference dialogWhen you create a cross-reference this way, Word
inserts a bookmark
around the target text. Word hides the bookmark it creates to mark
your reference target, but you can see its name if you look in the
Insert Figure 8-18. You can view your cross-reference bookmarks in the Bookmark dialogWord assigns the bookmark's name, something like "_Ref46516798," to make the bookmark unique. The leading underscore denotes a hidden bookmark. While the bookmark's name may be unique, it's not very useful. If you need to determine which bookmark belongs to which reference target, the list shown in Figure 8-19 offers little comfort. Figure 8-19. Word's decidedly unhelpful bookmark-naming convention for cross-referencesIdentifying specific bookmarks is an important part of troubleshooting cross-references, because bookmarks behave very, very strangely when you edit the text they enclose. For example, if you add text to the end of a heading that you cross-referenced and update the reference, the new text isn't included in the reference. Figure 8-20 shows this phenomenon using a manually created bookmark (so the ends are visible), but the same thing happens with Word's cross-reference bookmarks. Figure 8-20. When you add text at the end of a bookmarked paragraph, the bookmark doesn't expandThe solution? If you need to add text to a reference paragraph, you must put the new text before the last character and then delete the last character. But wait, it gets worse. Inserting text at the beginning of the paragraph works just fine, but if you hit Enter with your cursor at the beginning of the paragraph, the bookmark's beginning gets left behind, as shown in Figure 8-21. Figure 8-21. A wayward bookmarkNow that you've gotten a peek into the way Word cross-references work, you're ready to create your own cross-references between two different documents. 8.10.2 Create Cross-References with INCLUDETEXT Fields
To reference text in a different document, you can use the same general method Word does: mark the target with a unique bookmark and then reference the contents of the bookmark with a field.
For example, say you have a book with six chapters named "Chapter One," "Chapter Two," and so on. Chapter Two contains a section you want to reference in Chapter Three. First, open the document containing the target (Chapter Two in this
example) and go to the heading you want to reference. Select the
entire heading, except for the trailing
paragraph mark. Select Insert Figure 8-22. Choose a descriptive and unique name for your bookmarkClick the Add button to insert the bookmark. If
you've chosen to show bookmarks (select
Tools
Next, go to the document and find the location where you want the
reference to appear. Press Ctrl-F9 (or select Insert INCLUDETEXT "Chapter Two.doc" BookmarkName Note that you enclose the filename in quotes, but not the bookmark name. Select the field and press F9. The reference will now display the
bookmarked text. With "Field
shading" set to Always (select
Tools Figure 8-23. A cross-reference to an external Word document
With an INCLUDETEXT field, you insert more than just the bookmark's contents. The bookmark itself now appears in the reference document's list of bookmarks.
For more hacks about cross-referencing in Word, check out [Hack #43] and [Hack #44] . |