Updated October 2017

Following a number of enquiries and comments on this particular topic, we’ve refreshed and updated this article with information relevant to recent versions of Microsoft Office.

I recently had a piece of work to do for a client that appeared on the surface to be a simple task. Just mail merging a document using a standard excel spreadsheet. What I thought would be a quick job turned into something much longer when I discovered there were hyperlinks in the spreadsheet that needed including in the merged document.

Now, this is itself isn’t a problem, if all we wanted to do is display the full hyperlink in the final document. In this case, the merge would work, but the link itself would be transformed to plain text rather than a clickable link – annoying, but not the end of the world. This problem was one step more complicated than that! I wanted to display the same ‘link text’ (e.g. the words ‘click here’) on every merged document, but have a different link address (URL) for each document. There was a good reason for this, the letters were going out to individuals, directing them to their own personal page on a website, so we needed this level of personalisation and because the links were so long and ugly, the option to just display the the full link address on each page wasn’t possible.

In addition, we wanted to merge in the email address of their account manager, and make it clickable so that they can email their advisor with any problems.

There’s a great little workaround for creating dynamic links in a mail merge by adding a hyperlink field around the mail merge field; and here’s how to do it.

Step 1: Setup your mail merge

Firstly, set up your mail merge document as usual, adding merge fields the way that you would normally (Reminder: Mailings > Start Mail Merge > Select Recipients > Add merge field)

Now here is the important bit. If you want the full email address or URL as shown in your source data to show up in your merged document, then simply insert the mergefield in the usual way. However, if you want to place a link behind some standard text (i.e. “click here” as in this example) make sure that the link text that you want already appears in the body of your letter.

In the example below we are using the words ‘click here’. You can also see a sample of our Excel data, with the name of the recipient and their personalised web link.

Step 2: Create your hyperlink fields

When you are ready to insert your hyperlink fields, highlight the text that you want to use as your link text (in this case ‘click here’) and key CTRL+K to apply a hyperlink using the first URL from your list of data (Note: this can actually be any URL you choose, real or made up).

Do the same for your email field by highlighting the “email” merge field in your body text, press CTRL+K to open the hyperlink wizard then make sure you choose link type “email address” before typing any email address in the email address field.

What you’ll then see is that your email address field has changed to a clickable link email address.

Step 3: Create your dynamic links

Now comes the wizardry we need to create your dynamic links.

Press ALT+F9 to toggle your field codes, and you will see your link now displayed like this: { HYPERLINK “http://yourlinkhere.com” }

Merge_Hyperlinks3

 

You now need to change this code so that your merge field for the URL replaces the URL displaying currently. Do this by placing your cursor after the word ‘HYPERLINK’. Delete everything between the inverted commas and place your cursor there.

Now insert your merge field in the usual way by clicking Mailings tab > insert merge field > your merge field So for example if your merge field is “Page URL”, you need to put your cursor between the inverted commas after the word HYPERLINK and insert  the mergefield “Page URL”. The code will change to look like this:

{ HYPERLINK “{ MERGEFIELD PageURL }”}

Your finished document will look something like this…

Once you have inserted your merge fields and are happy with them, toggle the field codes again by pressing ALT + F9

You should notice that your links have merged to match the first row of data in your database. If you preview the document and hover over your links at this stage, it may look like the merge has worked, but worry not, this is ok. We will update the fields in the next step.

Step 4: Finish your merge

You can now proceed to finish your mail merge in the usual way.

Select Finish & Merge > Edit individual documents. The resulting document will have individual hyperlink fields and if you should see that the URL for each is personalised.

Merge_Hyperlinks5

 

There’s now one final step you have to do which is important.  You need to update all hyperlinks in the document. Do this by pressing CTRL+A to highlight the entire document, followed by F9.

Your hyperlinks should now be updated and your document is ready to be printed. You can check your hyperlinks by clicking on them or hovering over them to display the link address.

Merge_Hyperlinks6