Add Variable Hyperlink in Mail Merge in Word 2013

自作多情 提交于 2019-12-20 10:43:39

问题


I'm trying to add a hyperlink to a mail merge field. So something like this:

{HYPERLINK "{MERGEFIELD "Links" }"}

So I create a field like this.

{ MERGEFIELD Links }

And the above works (it displays different links for different recipients).

However, when I go to Edit Field, and then attempt to add HYPERLINK to { MERGEFIELD Links}, Word will not allow me. Meaning that when I type HYPERLINK followed by a space, the "variable" field is gone. Instead of word displaying...

LINK

it displays...

   {HYPERLINK "{MERGEFIELD "Links" }"}

even after I press "update field". So Word is not letting me enter HYPERLINK for some reason.

How do I solve this?


回答1:


From the Microsoft Web Site,

  1. On the Insert menu, click Field (under Quick Parts in later office versions).
  2. In the Field names list, click Hyperlink, and then click OK. The text Error! Hyperlink reference not valid appears in the document.
  3. Press ALT+F9 to open the { HYPERLINK \* MERGEFORMAT } field code.
  4. Put the insertion point after HYPERLINK and then add a space.
  5. On the Insert menu, click Field. In the Field names list, click MergeField. In the Field name text box, type the name of the data source field that contains the hyperlink, and then click OK. For example, if the name of the data source field is "Address1," the field code appears as follows: { HYPERLINK { MERGEFIELD "Address1" } \* MERGEFORMAT }
  6. Press ALT+F9 to close the field code. You now have Error! Hyperlink reference not valid text.
  7. Put the insertion point at some arbitrary place in the middle of the Error! Hyperlink reference not valid text, and insert the text you want to appear. If you would like a merge field, insert that from the "Insert Merge Field" option on the menu.
  8. Delete the remaining text of Error! ... before and after the text you want to keep.

Note: If your merge field only contains an identifier, with the URL to be provided as a static part of the merge document, this can work also. On Step 5, you will need to insert the URL text as well as the MergeField, for example: { HYPERLINK "https://www.myurl.com/EditForm.aspx?ID={ MERGEFIELD ID }" \* MERGEFORMAT }




回答2:


I also have been struggling with this. What I found to be the key is creating the document from SCRATCH and not saving it before executing the mail merge. Here are the steps I used:

  1. open a new document and click on the step by step mail merge wizard; add your generic text.
  2. To add the variable hyperlink go to insert>quick parts>fields
  3. select hyperlink on the left and click okay
  4. Use alt + F9 to see the hyperlink field code
  5. Type “” and between them insert your merged field so that {HYPERLINK \* MERGEFORMAT} -> becomes {HYPERLINK"{MERGEFIELD"Constructed_URL"}"\*MERGEFORMAT}
  6. Press ALT+F9 to hide the field code
  7. Click in the text "Error! Hyperlink reference not valid" and replace with something generic like click here.
  8. Complete the mail merge BEFORE you save the document.

Hope this helps and good luck!




回答3:


Start with the process here: http://support.microsoft.com/kb/912679 However, like user1867326 indicated, the hyperlink (which should be variable with the mail merge) is converted into a static link when the Word file is reopened.

A solution that seems to work is adding a bookmark within the hyperlink field code immediatly after the mergefield. { HYPERLINK { MERGEFIELD "Link" } \* MERGEFORMAT } Click between the } and \ and go to INSERT > Bookmark, give it a name, and this seems to prevent Word from replacing the mergefield with a static hyperlink.

This answer is adapted and hopefully clarified from the clever solution described here: Mailmerge dynamic hyperlink fields lost after save/reload of document - Word 2010




回答4:


This is what worked for me for an email mail merge with variable hyperlinks that all display the same text. I am using Office 2016 Word.

  1. Put the insertion point where you would like the link display text to be in the document.
  2. On the Insert menu, click Quick Parts, and select Field.
  3. In the Field Names list, click Hyperlink, and then click OK. The text Error! Hyperlink reference not valid appears in the document.
  4. Press ALT+F9 to open the { HYPERLINK * MERGEFORMAT } field code. 5. Put the insertion point after HYPERLINK.
  5. On the Insert menu, click Quick Parts, and select Field. In the Field Names list, click MergeField.
  6. In the Field name text box, type the name of the data source field that contains the hyperlink, and then click OK. For example, if the name of the data source field is "Address1," the field code appears as follows: { HYPERLINK { MERGEFIELD Address1 } * MERGEFORMAT }
  7. Press ALT+F9 to close the field code. You now have Error! Hyperlink reference not valid text.
  8. Put the insertion point just before the period in ‘Error! Hyperlink reference not valid text.’ and delete all the text except for the period. Write in the link display text. Make sure not to delete the period (this is important).
  9. To check that the hyperlinks are mapping, right click on the link display text and click edit hyperlink. You will see the correct link in the address field for each record.
  10. I like to style the period text color to white so it looks invisible.



回答5:


I have had limited success with the other suggestions - basically, Word is buggy in this area. There is a simple alternative - indeed the only alternative AKAIK if you want the hyperlink to vary AND the text that is displayed to vary too (not an unreasonable requirement).

Note that this only works for DOCUMENT MERGES, not for EMAIL MERGES, since it relies on processesing the output document.

The trick is to add a place marker (text that serves as an ID) wherever you want a hyperlink. Insert this via a regular mergefield. In your table of source data, you need columns

place marker, text_for_display, hyperlink

You then need to put your source data into Excel (if that isn't where you have it already) and put this formula

="Set Rng = ActiveDocument.Content: Rng.Find.Execute FindText:="""&[place marker]&""": ActiveDocument.Hyperlinks.Add Anchor:=Rng, Address:="""&[hyperlink]&""", TextToDisplay:="""&[text_for_display]&""""

into a blank column in the first row, and fill down.

You need to amend [place marker],[hyperlink] and [text_for_display] to the appropriate cell references.

If the [hyperlink] includes a query string, you may find you want to build it using a formula, based on other data in the source.

The resulting formulae can then be pasted into a macro and run on the output document.

You may then want to use the "Robbins/Mayor" macro http://www.wordbanter.com/showthread.php?t=18346 to split the generated documents.



来源:https://stackoverflow.com/questions/17428891/add-variable-hyperlink-in-mail-merge-in-word-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!