问题
I have a problem where using dynamic hyperlinks in field codes works fine when I create a document, but when save and later reload it the links are replaced with text from the original recordset. The field code I am using is:
{ HYPERLINK { MERGEFIELD "Fieldname" } \* MERGEFORMAT }
After saving then reloading the document this becomes similar to:
{ HYPERLINK "http://www.example.com" }
I am merging to HTML email.
I have been unable to get this to successfully work after saving. This is a simplified version of what I'm trying to do and the only part I can't get to work properly. I need to get the mail merge document prepared for someone else to run, rather than be there to set it up each time it needs to be run.
Any help on this would be much appreciated.
回答1:
In addition to inserting the { MERGEFIELD Fieldname } field, insert a uniquely named bookmark via Insert->Bookmark, say, immediately after the mergefield field.
I cannot guarantee that that will "work" in all circumstances, but so far it seems to do the trick. Another possibility if you do not want to have to remember any distinct bookmark names would be to insert a nested field like this instead:
{ SET "mfkeeper{ SEQ mfk }" " " }
If you do that, and update the nested SET field before doing anything else (such as updating the HYPERLINK field), you get a uniquely named bookmark (mfkeeper1, etc.). Whether that is sustainable, I cannot currently tell.
This behaviour gpes some way to explaining why the nested HYPERLINK behaviour seems so arbitrary - if you select the HYPERLINK fields and update them all via F9, Word inserts its _GoBack bookmark into the HYPERLINK field, and that's what seems to prevent Word from resolving the nested MERGEFIELD field.
来源:https://stackoverflow.com/questions/16817380/mailmerge-dynamic-hyperlink-fields-lost-after-save-reload-of-document-word-201