Graham Mayor

... helping to ease the lives of Microsoft Word users.

Many people access the material from this web site daily. Most just take what they want and run. That's OK, provided they are not selling on the material as their own; however if your productivity gains from the material you have used, a donation from the money you have saved would help to ensure the continued availability of this resource. Click the appropriate button above to access PayPal.

Hyperlink Mergefield Add-in for Word 2007 and later

Variable hyperlinks chosen from a mail merge data file are complicated to create especially if the hyperlink display text is also variable, or a the hyperlink is attached to merged graphics. This Word add-in aims to overcome that.

The add-in will not insert hyperlink fields in text boxes or in the header/footer ranges of the merge document. This is quite simply because hyperlinks in such locations do not work in Document format as the ranges themselves must first be selected to make the link accessible.

If the merge is intended to be split to separate files in PDF format, using the Many to One add-in, then it is permissible to use links in text boxes; so where this is a requirement, insert the link into the body of the document (or into another blank document attached to the same data source) and then drag the link to the required location.

The add-in puts a pair of buttons on the Mailings Tab of the Ribbon:

The first button runs the process, the second operates a drop-down menu with three commands.

  • The first is used to process documents that have already been merged and is explained later on the page.
  • The second is used following a merge to a new document. Unfortunately the merge fields do not update when merged (except when merged using the Many to One add-in) and so it is necessary to merge to a new document and use this button to update the fields in that document to reflect the correct data.
  • The third is used to reset the variables stored in the template.

The Update All Fields function is not limited to use with this add-in. It will update all fields in a document generally.

When activated the process determines that the document is a merge document and that a data source is attached. This is essential as the function will use that data source to apply the field structure to the document.

The dialog is self explanatory. Clicking the first check box alters the dialog to provide options for using a graphic as a hyperlink:

When graphics are used as links, the data source should not contain the path to the graphics files. It should contain only the filename, with or without the extension as shown below. The path is user selected as part of the process. Links must be in valid link format.

Using the above data source as an example (a Word table) the four pictures refer to four rectangular coloured blocks, however in a real world situation you can use any practical graphics:

 

Depending on the options chosen you would see either the link, the display text or the image inserted into the document.

Because of the complexity of inserting the links into tables, including labels, I have trapped such insertions and a message (below) advises how to proceed. The use of a temporary merge document will inevitably be required when using the links in conjunction with a merge to mailing labels. (See also Graphics on Labels).

The final illustrations show how a graphic link has been inserted into a table cell used in a directory merge.

 

Replace Display Texts with Hyperlinks

The add-in includes a second major function, the first item in the drop down section of the Ribbon group. The purpose of this function is to replace display texts in a document, with hyperlinks that relate to those display texts, from an Excel data file that includes the display text, the URL to be linked to and optionally a screen tip text.

The document being processed could be the result of a mail merge or a document that has a variety of texts that need to be hyperlinked. It cannot be a merge document.

Only Excel data files may be used with this function, to list the texts to be found and the hyperlinks (and screen tip texts if used) that relate to those texts.

The datasheet need not be the data source used for the original merge.

Where the data source used for the original merge contains the hyperlink data, the main function described at the start of this page could be used instead.

Note: If the texts to be hyperlinked are already the URLs to be linked to, Word's built-in autoformat function should be used to convert such texts to hyperlinks. The Replace Texts with Hyperlinks function is used with texts that are NOT the URLs to be linked to.

This part of the add-in evolved separately, but as it is so closely related to the mail merge function and shares several code modules, I decided to include it from Version 2 in the same add-in as the mail merge function.

The function has a separate but similar userform as shown below.

The example shown below is a simple directory merge document. It features a simple description and a code that relates to the description. When merged to a new document, you get a list of the merged items and their codes (I have only shown the beginning of the list).

The function can be used to replace the codes (or the descriptions, or - in two operations - both) with hyperlinks to the web pages etc. that relate to those codes or descriptions.

 

- Click here to download the add-in

 

 

 Hyperlinks

This add-in was originally developed to help overcome the difficulty of using merged hyperlinks with variable display texts.