方法 2: 创建一个宏来动态地修改超链接文本
Microsoft 提供的编程示例仅用于说明,没有任何明示或暗示的担保。这包括但不限于适销性或特定用途适用性的暗示担保。本文假定您熟悉所演示的编程语言和用于创建和调试过程的工具。Microsoft 的支持工程师可以帮助解释某个特定过程的功能,但是他们不会修改这些示例以提供额外的功能或构建过程以满足您的特定要求。创建一个宏,如果要动态修改合并的电子邮件中的超链接文本。这些步骤后,则超链接显示文字所基于的数据源中的 URL。若要执行此操作,请执行以下步骤:
请按照本文"方法 1: 添加超链接字段在邮件合并字段周围。"
在工具菜单上,指向宏,然后单击Visual Basic 编辑器。
按 f7 键。此时将显示代码窗口。
复制并将以下代码粘贴到代码窗口中:
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
在工具菜单上,指向宏,然后单击宏。
单击MergeToEmail,然后再单击运行。
注意:通过使用此宏发送每封电子邮件,从 Microsoft Outlook 的警告消息出现。有关此问题的详细信息,请单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
290498您可以收到警告消息,当您在 Outlook 2002 中使用第三方加载项或自定义解决方案