Microsoft KB Archive/912679

= 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 ID: 912679

Article Last Modified on 3/23/2006

-

APPLIES TO


 * Microsoft Office Word 2003
 * Microsoft Word 2002 Standard Edition

-



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:  Start Word and open the document that you want to merge to e-mail. On the Tools menu, point to Letters and Mailings, and then click Mail Merge. The Mail Merge Wizard appears. Under Select document type, click E-mail messages, and then click Next. Under Select the starting document, click Use the current document, and then click Next. Under Select recipients, select the recipients that you want to use, and then click Next. Put the insertion point where you want the hyperlink to appear in the e-mail message.</li> On the Insert menu, click Field.</li> In the Field names list, click Hyperlink, and then click OK. The text &quot;Error! Hyperlink reference not valid&quot; appears in the document.</li> Press ALT+F9 to open the { HYPERLINK \* MERGEFORMAT } field code.</li> Put the insertion point after HYPERLINK and then add a space.</li> On the Insert menu, click Field.</li> In the Field names list, click MergeField.</li> 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 &quot;Address1,&quot; the field code appears as follows:

{ HYPERLINK { MERGEFIELD &quot;Address1&quot; } \* MERGEFORMAT }

</li> Press ALT+F9 to close the { HYPERLINK { MERGEFIELD &quot; &quot; } \* MERGEFORMAT } field code.</li> Put the insertion point at the start of the &quot;Error! Hyperlink reference not valid&quot; 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.

</li> Select the text that you typed in step 15. In the Style list, click Hyperlink.</li> In the Mail Merge Wizard, click Next, and then follow the remaining steps in the Mail Merge Wizard to complete the mail merge process.</li></ol>

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: <ol> Follow the steps in &quot;Method 1: Add a hyperlink field around the mail merge field.&quot;</li> On the Tools menu, point to Macro, and then click Visual Basic Editor.</li> Press F7. The code window appears.</li>  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 &quot;Enter Your Subject Here&quot; or            ' remove the following line if you do not want a subject ActiveDocument.MailMerge.MailSubject = &quot;Enter Your Subject Here&quot; 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 </li> On the Tools menu, point to Macro, and then click Macros.</li> <li>Click MergeToEmail, and then click Run.</li></ol>

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

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_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

Additional query words: mailmerge

Keywords: kbtshoot kbbug kbmerge kbprb kbexpertiseinter KB912679

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.