Detect Mail Merge from Word

J

Jim Leach

Hello,

I have a COM Addin for Outlook written in VB6 that detects when items are
added to the SentItems folder's Item collection and potentially displays a
dialog box.

If a user performs a "Mail Merge to E-mail" from Word I want to temporarily
disable my dialog box from showing until the merge is complete.

Is there a way to detect that this mail merge is in progress, from either
the Outlook or Word object models? BTW - I am also using Redemption in my
solution.

Regards,

Jim Leach
 
E

Eric Legault [MVP - Outlook]

Yes, I believe you can do this. There's a MailMergeBeforeMerge event in Word
you can hook into, but you'll need to have this code running in Word's
context - either as a VBA macro hooked into normal.dot, or as a Word COM
Add-In. When the event fires, you can communicate with your Outlook Add-In.
 
J

Jim Leach

Thanks for your reply Eric,

I was HOPING I could detect the mail merge from the Outlook side... :)

Is there perhaps some property of the Sent Item I can get at with Redemption
that would tell me it is the product of a mail merge?

Regards,

Jim Leach
 
E

Eric Legault [MVP - Outlook]

I think you can detect the mail merge from Outlook as well - just declare
this in your module:

Private WithEvents objWord As Word.Application

Then you can work with the event:

Private Sub objWord_MailMergeBeforeMerge(ByVal Doc As Word.Document, ByVal
StartRecord As Long, ByVal EndRecord As Long, Cancel As Boolean)

End Sub

You just need to set objWord to a new or existing instance of Word when you
need to start monitoring for a mail merge.

I don't know off-hand if there are any unique properties put into an e-mail
if it was created with a mail merge. If you took control of the process, you
could do that yourself.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 

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