加载用于邮件合并的数据源时,该事件发生。
Private Sub object_MailMergeDataSourceLoad(ByVal Doc As Document)
object 在类模块事件中声明的 Application 类型对象。有关使用 Application 对象事件的详细信息,请参阅使用 Application 对象事件。
Doc 邮件合并主文档。
该示例在开始加载数据源时,显示一条包含数据源文件名的消息。该示例假定在一般声明中声明了一个名为 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 filename
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