Add Variable Hyperlink in Mail Merge in Word 2013
Asked Answered
K

8

14

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?

Kilk answered 2/7, 2013 at 14:56 Comment(0)
C
25

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 }

Codycoe answered 10/6, 2016 at 19:12 Comment(3)
That one's for 2003 as well, no insert > field anymore.Laflamme
I'm not sure what you are talking about, I'm using Office 2013 and these steps worked for me.Codycoe
The "insert > fields" step in Word 2013 is now on Insert Ribbon > Text Panel > then the top middle button, here you will find the Field option.Sciomancy
B
12

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!

Barren answered 18/9, 2013 at 18:15 Comment(1)
Last step #8 is not necessary if you follow answer of LeniusC -- click in to the MERGEFORMAT and insert bookmark.Aliped
I
9

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

Impower answered 22/11, 2013 at 16:4 Comment(4)
It would be helpful if, instead of referring to an outside process, you pulled the relevant pieces into here.Codycoe
That article is for Office 2003, and this was for 2013. Instruction 7 makes no sense in that article and I think the process is totally different now.Laflamme
Instruction 7 makes no sense in that article and I think the process is totally different now. I tried to insert that code above where it says {HYPERLINK... but it doesn't seem to recognize that.Laflamme
When I tried to follow these instructions, I had trouble getting the link to appear properly. I was using Word 2016 on Windows. To fix it, I had to do this: Instead of typing {MERGEFIELD "Link"} by hand, I had to insert the field using the Insert menu. The issue seems to be that typed curly braces are not the same as those inserted by Word when you use the Insert command!Slackjawed
F
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.
False answered 21/5, 2019 at 19:42 Comment(0)
B
0

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.

Bolling answered 1/11, 2019 at 10:50 Comment(0)
A
0

I got this working thanks to this thread, but then it stopped working and I figured out why so I thought I'd say thanks by posting what I discovered here.

The issue is that word has a special type of curly brace. Copying the code text from this thread may not work for that reason. To get the curly braces Word wants, I used Fn + Command + F9 on my Mac running Catalina and Office 365. Apparently some Mac users may find Command + F9 works -- just test to find out. I'm sure Windows has a similar keystroke set. I found the Mac solution in this post.

Also, the syntax that works for me is: { HYPERLINK { MERGEFIELD "url" } * MERGEFORMAT } where "url" is the label of the column with the link in my Excel file. Note the position of the quotes. This differs from other posts here (I tried the other combinations) but I wouldn't be surprised if the syntax may vary across Word versions and operating systems.

Abcoulomb answered 27/1, 2020 at 0:24 Comment(0)
A
0

To get this method to work in Mac Office 365 (Big Sur), you need to know about the Toggle Field Codes in the context menu. The shortcut above to replicate the Alt-F9 behavior will create a new field, instead of allowing you to edit the field that exists.

At these steps:

Press ALT+F9 to open the { HYPERLINK * MERGEFORMAT } field code.

OR

Press ALT+F9 to close the field code. You now have Error! Hyperlink reference not valid text.

Instead of the keyboard shortcut, right click on the error message and select Toggle Field Codes from the context menu.

Answer worked great for me with this adjustment! Thank you!

Abracadabra answered 18/1, 2021 at 19:49 Comment(0)
T
0

LeniusC's workaround for the hyperlink being removed on file save has a small caveat that left me confused, thinking the workaround doesn't work in Word 2013 or I was doing something wrong - while it solves the issue when manually saving the file, it does not solve it when "Finish & Merge" is executed. This isn't as much of an issue once you're aware of it, since you can either simply not save the changes after the merge is done (so if you're making any changes to the document, it's best to save them before the merge), or set the file as read-only.

Titoism answered 10/3, 2023 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.