Detect Mail Merge from Word

  • Thread starter Thread starter Jim Leach
  • Start date Start date
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
 
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.
 
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
 
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/
 
Back
Top