VBA mailmerge event

F

Fev

Hi
I am writing vba code to modify a mailmerge (Word 2003) document prior
to merging, based on a value in the datasource. The merge itself is
handled by the property management system "Nicor", and each merge uses
a temp datasource file created by Nicor. I am trying to use the
MailMergeDataSourceLoad event to trigger the macro to edit the
document prior to merging without success. This is what I have so
far:
In the VBA module 1:

Public mm As New clsMergeEvents

Sub InitEvents()
Set mm.appWd=Word.Application
End Sub

Sub SetUpComm()
code to set up the merge document with bookmarks, field calculations
and specific number of rows in tables based on the datasource
information
....
End sub

In the Class module called clsMergeEvents:

Public withEvents apWd as Word.Application

Private Sub appWd_MailMergeDataSourceLoad(ByVAl Doc as Document)
MsgBox "Your macro will now run"
Module1.SetUpComm
End Sub

In the document code:
Private Sub Document_Open()
InitEvents
End Sub

I have tested it using the MailMergeBeforeRecordMerge Event and as
stated in previous posts it only works from the task pane screen, but
works! At this stage I am testing the macro outside of Nicor, simply
manually attaching the datasource. As I have no control of the merge
process or the attaching of the datasource or the datasource name, I
thought that this may work. Any help would be hugely appreciated.
Thanks
 

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