Application.MailMergeDataSourceLoad 事件 (Word)

在为邮件合并加载数据源时发生。

语法

表达式MailMergeDataSourceLoad (Doc)

表达 一个变量,表示已使用类模块中的事件声明的“Application”对象。 有关对 Application 对象使用事件的信息,请参阅 将事件与 Application 对象配合使用

参数

名称 必需/可选 数据类型 说明
Doc 必需 Document 邮件合并主文档。

示例

以下示例在开始加载数据源时,显示一条包含数据源文件名的消息。 该示例假定在一般声明中声明了一个名为 MailMergeApp 的应用程序变量,并将 Word Application 对象赋给该变量。

Private Sub MailMergeApp_MailMergeDataSourceLoad(ByVal Doc As Document) 
 Dim strDSName As String 
 Dim intDSLength As Integer 
 Dim intDSStart As Integer 
 
 'Extract from the Name property only the file name 
 intDSLength = Len(Doc.MailMerge.DataSource.Name) 
 intDSStart = InStrRev(Doc.MailMerge.DataSource.Name, "\") 
 intDSStart = intDSLength - intDSStart 
 strDSName = Right(Doc.MailMerge.DataSource.Name, intDSStart) 
 
 'Deliver a message to user when data source is loading 
 MsgBox "Your data source, " & strDSName & ", is now loading." 
End Sub

另请参阅

Application 对象

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。