R
Roberto Castro
Hello!
I know this topic has been mentioned before but I am trying to run the
example available on MSDN but still cannot make it work. I want to use
this idea in a bigger application but first I want to see the example
running.
I have a Word 2002 document that performs mail merge. This part works
ok. I want to run a macro after each record's merge is done. And this
is the part I need help with. Here is my code:
'
' Code is stored in ThisDocument object
'
Private WithEvents MailMergeApp As Application
Sub InitializeMailMergeApp()
Set MailMergeApp = Publisher.Application
End Sub
Private Sub MailMergeApp_MailMergeAfterRecordMerge(ByVal Doc As
Document)
MsgBox "I am here", vbOKOnly
With Doc.MailMerge.DataSource
MsgBox "Hello", vbQuestion, "Title"
'MsgBox .DataFields(1).Value & " " & _
' .DataFields(2).Value & " is finished merging."
End With
End Sub
As you can see is just a copy from the example given at MSDN site, so
what's missing? Is there anything else I have to set up or define in
the Word document or in the VBA code? The InitializeMailMergeApp code
should run by itself when the object is created, right?
Any help would be appreciated.
Thanks!
Jose
I know this topic has been mentioned before but I am trying to run the
example available on MSDN but still cannot make it work. I want to use
this idea in a bigger application but first I want to see the example
running.
I have a Word 2002 document that performs mail merge. This part works
ok. I want to run a macro after each record's merge is done. And this
is the part I need help with. Here is my code:
'
' Code is stored in ThisDocument object
'
Private WithEvents MailMergeApp As Application
Sub InitializeMailMergeApp()
Set MailMergeApp = Publisher.Application
End Sub
Private Sub MailMergeApp_MailMergeAfterRecordMerge(ByVal Doc As
Document)
MsgBox "I am here", vbOKOnly
With Doc.MailMerge.DataSource
MsgBox "Hello", vbQuestion, "Title"
'MsgBox .DataFields(1).Value & " " & _
' .DataFields(2).Value & " is finished merging."
End With
End Sub
As you can see is just a copy from the example given at MSDN site, so
what's missing? Is there anything else I have to set up or define in
the Word document or in the VBA code? The InitializeMailMergeApp code
should run by itself when the object is created, right?
Any help would be appreciated.
Thanks!
Jose