Hyperlinks in data source fields are converted to plain text when you perform a mail merge on e-mail messages in HTML format in Word 2002 and Word 2003

Article translations Article translations
Article ID: 912679 - View products that this article applies to.
Expand all | Collapse all

SUMMARY

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

SYMPTOMS

When you perform a mail merge on e-mail messages in HTML format by using the Mail Merge Wizard or by using the Merge to E-mail command in Microsoft Word 2002 or in Microsoft Office Word 2003, the hyperlinks in data source fields are converted to plain text.

WORKAROUND

To work around this problem, use either of the following methods, depending on your situation.

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 Tools menu, point to Letters and Mailings, and then click Mail Merge. The Mail Merge Wizard appears.
  3. Under Select document type, click E-mail messages, and then click Next.
  4. Under Select the starting document, click Use the current document, and then click Next.
  5. Under Select recipients, select the recipients that you want to use, and then click Next.
  6. Put the insertion point where you want the hyperlink to appear in the e-mail message.
  7. On the Insert menu, click Field.
  8. In the Field names list, click Hyperlink, and then click 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. On the Insert menu, click Field.
  12. In the Field names list, click MergeField.
  13. 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 }
  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 do not delete the whole field.
  16. Select the text that you typed in step 15. In the Style list, click Hyperlink.
  17. In the Mail Merge Wizard, click 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 click 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 click Macros.
  6. Click MergeToEmail, and then click Run.

Note For each e-mail message that you send by using this macro, a warning message from Microsoft Outlook appears. For more information about this behavior, click the following article number to view the article in the Microsoft Knowledge Base:
290498 You receive warning messages when you use a third-party add-in or custom solution in Outlook 2002

STATUS

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, click the following article number to view the article in the Microsoft Knowledge Base:
294694 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, click the following article number to view the article in the Microsoft Knowledge Base:
305326 List of programming resources for Visual Basic for Applications

Properties

Article ID: 912679 - Last Review: March 23, 2006 - Revision: 2.2
APPLIES TO
  • Microsoft Office Word 2003
  • Microsoft Word 2002 Standard Edition
Keywords: 
kbbug kbmerge kbexpertiseinter kbprb kbtshoot KB912679

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com