The problem occurs during the merge and is caused by the fact that Merge
destroys the ToC field, leaving the underlying references to the pages that
headings and/or TC fields are on (either PAGEREF or HYPERLINK fields,
depending on the switches in the ToC field) and destroys all bookmarks, so
the "targets" of the PAGEREF or HYPERLINK fields also disappear.
It's difficult to know what you could do about this in a generic automated
merge unless the merge knows that it has to do something special for the one
document with a ToC. Logically speaking, what you probably need to do is
a. detect whether or not there is a ToC
b. If there is, save all the information necessary to recreate the ToC (ToC
switches, location, and perhaps style info. related to the various ToC
paragraph styles)
c. replace the ToC by some kind of placeholder text, or otherwise remember
its position, during the merge
d. After the merge, re-insert the ToC field, restore any other settings
such as paragraph style settings, and re-execute the ToC field
Alternatively, you could do something like get the users to put the ToC
field in an INCLUDETEXTed document, do the merge, and re-execute that field,
but there are various possible gotchas with that approach.
Peter Jamieson
>I have a program that takes data from an Excel spreadsheet and inserts
> into a series of word documents using a mailmerge powered by VBA. I
[quoted text clipped - 19 lines]
>
> Rasheq