MailMergeAfterRecordMerge event not running

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top