Francis has multiple documents that, for the purposes of a Table of Contents, he needs to treat as a single document. He wonders if there is a way to create a Table of Contents that actually spans multiple documents.
There are actually three ways to go about this. I'll quickly describe two of the approaches and then spend a bit more time on the third.
The first approach is to simply create a new document and then copy the contents of each of your files into that new document, in the proper order. Let's say that you have a series of documents named Chap01, Chap02, Chap03, and on through Chap32. You would open each of these files, in turn, press Ctrl+A to select everything in the file, switch to the new document, and press Ctrl+V. As you do this, the new document gets larger and larger (of course), but when completed you can easily add a TOC to the beginning of the document.
Quite honestly, that approach is a lot of work, and it isn't terribly flexible. Every time you edit one of the documents you need to repeat the process to get a new TOC. So, I wouldn't recommend this particular approach.
The second approach is to use a master document and subdocuments. This is a feature built into Word that allows you to define a "container document" (the master document) and identify other documents that should be included in the container (the subdocuments). To create a master document, follow these steps:
If you decide to use this approach (creating a master document), understand that there are numerous horror stories related to their use. Many people consider master documents to be the fastest available way to Word document corruption. Because this is a possibility, you'll want to make sure you protect yourself by keeping backup copies of all of your original documents without those backups being part of a master document. You can find more information about corruption of master documents at this page on the Word MVP site:
http://wordmvp.com/FAQs/General/WhyMasterDocsCorrupt.htm
The third approach is to use field codes to combine the documents into a single document. This approach has the fewest number of drawbacks that I can find, so it is the one that I would suggest. Follow these steps:
Figure 1. The Field dialog box.
Even though the RD field-code route is the safest approach, understand that if you are using Word 2013 you may experience a bug in the implementation of RD codes. You'll know if you've encountered the bug if the generated page numbers for a file are all the same. You can apparently work around the bug by having all of the referenced files open in Word when you generate (or regenerate) the TOC. You could also, if desired, change all the RD field codes to INCLUDETEXT field codes, but if you choose to do so you will need to put a section break before and after each of the field codes.
If you want some additional information on using this third approach, check out these resources:
http://mousetrax.com/mastdoc.html
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (3318) applies to Microsoft Word 2007, 2010, and 2013.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!
Word includes a couple of built-in tools that rely upon the use of heading styles in your document. These tools include ...
Discover MoreA table of contents is a great way to help organize lengthy documents. In a default TOC, you can use each entry as a ...
Discover MoreIf you generate a table of contents for your document, there may be some unexpected surprises in the way the TOC appears. ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-10-30 12:41:40
Roy Wall
Like Rachel Kyle, below, I have had trouble getting, e.g., clicked page-numbers in my TOC document to go to the corresponding place in a document mentioned using an RD field in the TOC document.
2020-05-07 12:50:45
Rachel Kyte
I have a large number of documents with individual TOCs as well as a single document which contains a TOC of all the other documents which I created using the RD command. I have now created separate PDFs of all the files and combined them into a complete document. In the final PDF the hyperlinks in the TOCs all work except for the master one created using the RD command. Is this even possible? Any help would be very much appreciated. Thank you.
2019-12-12 17:26:50
peter roth
Allen - mousetrax website is now about K9 pillows rather than Word ...
2019-10-16 14:13:32
Irene
Is it possible to have the TOC link to the specific section by clicking on the page number/section name? Like you can when your TOC and sections are within the same document. Better yet, I would prefer that when I PDF the sections together that the TOC would have the CTRL + CLICK option.
2019-10-07 16:07:32
Jennifer
How do you input the filename in step #7 of approach 3? I've tried the location path on my machine, just the filename (with and without .docx included) and the TOC can't find the file I'm referencing in the field code.
2017-07-24 19:46:41
Rika
Is the RD field version limited to 7 documents? I can't seem to add anything after Chapter 7.
2017-02-17 02:59:22
Tara
Can this also be done with a table of authorities (putting it in a separate document than the one containing the marked cites)?
2016-12-29 13:56:55
Gordon M
Just as an update, I had the same bug in Word 2013, but eventually it was fixed in a Word update (I think some time in 2014 or 2015). Word 2016 also does not have this issue.
Using the RD method, is there any way to create a PDF file of the final document (with all the documents included), and for that PDF to include hyperlinks from all the TOC entries to the correct locations in the PDF?
2015-10-03 04:45:15
Ken Endacott
The macro:
Sub MultipleFilesTOC()
Dim fl As String
Dim flNames() As String
Dim flCount As Long
Dim j As Long
Dim k As Long
Dim TOClevels As Long
Dim mydir As String
Dim aString As String
Dim projName As String
Dim fldType As Long
' ----- Delete any existing TOC and RD fields -----
j = ActiveDocument.Fields.Count
If j > 0 Then
For k = j To 1 Step -1
fldType = ActiveDocument.Fields(k).Type
If fldType = wdFieldTOC Or fldType = wdFieldRefDoc Then ActiveDocument.Fields(k).Delete
Next k
End If
' ----- set generic name to current file name -----
projName = ActiveDocument.Name
mydir = ActiveDocument.Path
TOClevels = 3
' ------ get list of files in directory ------
j = InStr(projName, ".")
aString = Left(projName, j - 1) & "*" & Mid(projName, j)
flCount = 0
ReDim flNames(0)
fl = Dir(mydir & "" & aString)
Do While fl <> ""
If UCase(fl) <> UCase(ActiveDocument.Name) Then
flCount = flCount + 1
ReDim Preserve flNames(flCount)
flNames(flCount) = fl
End If
fl = Dir()
Loop
If flCount = 0 Then
MsgBox "No files found"
Exit Sub
End If
' ----- sort file names -----
For j = 1 To UBound(flNames) - 1
For k = j + 1 To UBound(flNames)
If flNames(j) > flNames(k) Then
fl = flNames(j)
flNames(j) = flNames(k)
flNames(k) = fl
End If
Next k
Next j
' ----- Create TOC and RD fields -----
Selection.Fields.Add _
Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False, _
Text:="TOC o " & Chr(34) & "1-" & Trim(Str(TOClevels)) & Chr(34) & " h z u"
For j = 1 To UBound(flNames)
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False, _
Text:="RD " & Chr(34) & flNames(j) & Chr(34) & " f"
Next j
ActiveDocument.TablesOfContents(1).Update
ActiveWindow.View.ShowFieldCodes = False
End Sub
2015-10-03 04:36:41
Ken Endacott
The fourth approach is to use a macro to generate the TOC and RD fields.
This following macro will create a Table of Contents from several documents having the same generic name. The TOC will be created in the current document after deleting any existing TOC and RD fields.
1. Give documents generic names for example MydocChapt01, MydocChapt02 etc. They must be in the same folder.
2. Adjust page numbering in the documents to give number spanning.
3. The front document should have the generic name in this case Mydoc. It may for example contain the title page and summary and can include heading paragraphs.
4. Set the variable TOClevels to give the number of levels in the TOC.
5. Position the cursor at the position where you want the TOC and run the macro
THE POSTING SOFTWARE IS PREVENTING ME FROM INCLUDING THE MACRO LISTING
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments