MailMerge events not firing.

T

TOM

I am experienced in VB and have Word2003 on XP Pro.

My MailMerge form has a datasource and works fine when
merging and presenting data.

I have a Class Module (Class1) in my Form with the code:
Public WithEvents MailMergeApp As Word.Application

In the Document_Open event of the 'ThisDocument' module
of my Form I have:
Dim X As New Class1
Set X.MailMergeApp = Word.Application
This code definitely executes.

However the code in MailMergeApp events does not execute.
The code is in my Class1 module.
 
D

Dreamboat

Hi, Tom. I'm no coder. But I've never seen mail merge code in a Class module. It's always right in the ThisDocument Document_Open (If it's a DOC Word document) and in the Document_New (if it's a DOT Word template)

<-*-><-*-><-*-><-*-><-*-><-*-><-*-><-*->
Hope this helps!
Anne Troy
Author: Dreamboat on Word
Email: Dreamboat*at*Piersontech.com
Web: www.TheOfficeExperts.com
 
C

Cindy M -WordMVP-

Hi Tom,

Which mailmerge events are you trying to intercept?

Also, I believe variable you use to activate the events in a class module has to be declared at the module level, not within a procedure. So

Dim X as New Class1

needs to be at the top of the ThisDocument module, not within the _Open event?
I am experienced in VB and have Word2003 on XP Pro.

My MailMerge form has a datasource and works fine when
merging and presenting data.

I have a Class Module (Class1) in my Form with the code:
Public WithEvents MailMergeApp As Word.Application

In the Document_Open event of the 'ThisDocument' module
of my Form I have:
Dim X As New Class1
Set X.MailMergeApp = Word.Application
This code definitely executes.

However the code in MailMergeApp events does not execute.
The code is in my Class1 module.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :)
 
T

TOM

At this stage I am trying to intercept ANY mailmerge
event. I have a MSGBOX in them ALL.

I have moved the declaration to the module level as
suggested but to no avail.
Hi Tom,

Which mailmerge events are you trying to intercept?

Also, I believe variable you use to activate the events
in a class module has to be declared at the module level,
not within a procedure. So
Dim X as New Class1

needs to be at the top of the ThisDocument module, not within the _Open event?


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-
mail :)
 
C

Cindy M -WordMVP-

Hi Tom,

On my webiste, Mail merge FAQ, Word 2002 section there's a section on VBA in Word 2002, with a topic on mail merge events. There's a sample file in there. Will that work on your machine?

Do you have access to another machine, where you can test?
At this stage I am trying to intercept ANY mailmerge
event. I have a MSGBOX in them ALL.

I have moved the declaration to the module level as
suggested but to no avail.

in a class module has to be declared at the module level,
not within a procedure. So

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :)
 
T

TOM

Hi Cindy

I should have looked at your website before posting as I
have used it before. BTW thanks for ALL your efforts.

It will take me some time to digest the sample as I have
a lot on my plate now.

I dare say using the sample I'll be able to resolve my
problem.

Thanks again.

Tom
Hi Tom,

On my webiste, Mail merge FAQ, Word 2002 section there's
a section on VBA in Word 2002, with a topic on mail merge
events. There's a sample file in there. Will that work on
your machine?
Do you have access to another machine, where you can test?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-
mail :)
 

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