When you perform a mail merge to e-mail messages in HTML format in Microsoft Word, the hyperlinks in data source fields appear as plain text and are inactive. This article describes two methods to work around this problem.

Method 1: Add a hyperlink field around the mail merge field

Add a hyperlink field around the mail merge field to generate a hyperlink in the merged e-mail messages. After you follow these steps, the hyperlink displays the same text in all the e-mail messages. Additionally, the hyperlink connects to the correct data source URL.

To do this, follow these steps:

  1. Start Word and open the document that you want to merge to e-mail.

  2. On the Mailings tab of the Ribbon select Start Mail Merge. Select Step-by-Step Mail Merge Wizard... and the Mail Merge Wizard appears on right hand side.

  3. Under Select document type, select E-mail messages, and then select Next.

  4. Under Select the starting document, select Use the current document, and then select Next.

  5. Under Select recipients, select the recipients that you want to use, and then select Next.

  6. Put the insertion point where you want the hyperlink to appear in the e-mail message.

  7. From the Quick Parts menu in the Text section of the Insert Ribbon tab, select Field.

  8. In the Field names list, select Hyperlink, and then select OK. The text "Error! Hyperlink reference not valid" appears in the document.

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

  10. Put the insertion point after HYPERLINK and then add a space.

  11. From the Quick Parts menu in the Text section of the Insert Ribbon tab, select Insert Merge Field.

  12. In the Field names list, select MergeField.

  13. In the Field name text box, type the name of the data source field that contains the hyperlink, and then select OK. For example, if the name of the data source field is "Address1," the field code appears as follows:

    { HYPERLINK { MERGEFIELD "Address1" } \* MERGEFORMAT }

  14. Press ALT+F9 to close the { HYPERLINK { MERGEFIELD "<Field Name>" } \* MERGEFORMAT } field code.

  15. Put the insertion point at the start of the "Error! Hyperlink reference not valid" text, and overwrite the text with the hyperlink text that you want to appear. For example, overwrite the text with text such as CLICK HERE.

    Important: Make sure that you don't delete the whole field.

  16. Select the text that you typed in step 15. Select on the lower right disclosure button on the Styles section of the Home tab of the ribbon, and then select Hyperlink.

  17. In the Mail Merge Wizard, select Next, and then follow the remaining steps in the Mail Merge Wizard to complete the mail merge process.

Method 2: Create a macro that dynamically modifies the hyperlink text

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures.

Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Create a macro if you want to dynamically modify the hyperlink text in your merged e-mail messages.

After you follow these steps, the hyperlink displays text that is based on the URL in the data source. To do this, follow these steps:

  1. Follow the steps in "Method 1: Add a hyperlink field around the mail merge field."

  2. On the Tools menu, point to Macro, and then select Visual Basic Editor.

  3. Press F7. The code window appears.

  4. Copy and paste the following code into the code window:

    Sub MergeToEmail()
    
        Dim bDone As Boolean
        bDone = False
    
        Do While bDone = False
    
            ActiveDocument.Fields.Update
    
            For Each oHyperlink In ActiveDocument.Hyperlinks
                oHyperlink.TextToDisplay = oHyperlink.Address
                oHyperlink.Range.Font.Color = wdColorBlue
                oHyperlink.Range.Font.Underline = wdUnderlineSingle
                oHyperlink.Range.Font.UnderlineColor = wdColorBlue
            Next oHyperlink
    
            With ActiveDocument.MailMerge
                .Destination = wdSendToEmail
                .SuppressBlankLines = True
                ' You can modify the text "Enter Your Subject Here" or 
                ' remove the following line if you do not want a subject
                ActiveDocument.MailMerge.MailSubject = "Enter Your Subject Here"
                With .DataSource
                    .FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
                    .LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
                End With
                .Execute Pause:=False
            End With
    
            If ActiveDocument.MailMerge.DataSource.ActiveRecord = _
                ActiveDocument.MailMerge.DataSource.RecordCount Then
                bDone = True
            End If
            ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
        Loop
    End Sub
    
    
  5. On the Tools menu, point to Macro, and then select Macros.

  6. Select MergeToEmail, and then select Run.

Note: For each e-mail message that you send by using this macro, a warning message from Microsoft Outlook appears.

Warning: Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

More Information

For more information about how to use the mail merge functionality to create e-mail messages, go to: How to use mail merge to create e-mail messages in Word 2002.

For more information about how to obtain help with Visual Basic for Applications, go to:

305326 List of programming resources for Visual Basic for Applications  

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.