mail merge with attachments

A

AS

Hello,

I found this article with details on a macro to have an attachment with a ma
il merge:

http://word.mvps.org/faqs/mailmerge..Attachments.htm

It works nicely if you just run the macro but if you want to merge fields in
a mail merge document itself it will not do it.
I guess the part I am not getting is, I would like to run the mail merge and
have the macro run after the fields are populated in the word document. Th
is would fill the fields required with the pertinent information then attach
the applicable attachment.
By just running the macro, the mail merge runs and attaches the document but
the fields in the word document only show the merge fields (not actual valu
es).
Does anyone know how to do this? The document says:


'Then execute the mail merge that you want to send out by email with the att
achments and with the result of execution of that mail merge on the screen,
run a macro containing the following code. When the File open dialog appear
s, select the file containing the table created by the catalogue type mail m
erge.'

From the sounds of this, the mail merge should run as normal then call up th
e macro to add the attachment. But, in my case, the mail merge runs without
calling up this macro - any ideas?
 
D

Doug Robbins - Word MVP

YOU have to run the macro which is what " and with the result of execution
of that mail merge on the screen,
run a macro containing the following code. " says. You must also follow
exactly all of the steps in the process if you want it to work.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
A

AS

Thanks for the reply Doug,

I think I am missing something on this though. I followed the document to a
T but when I run the macro, the first merge works fine. The fields in the
first email message are filled in according to the data source and the
appropriate attachment is in the message.
All subsequent messages are sent with the proper attachments but the email
messages are blank. No text, no merged fields, just blank.
I am using Word 2003 as the directory / catalog and actual document to
merge. I am using excel 2003 as the data source. I am using Outlook 2003
setup to an exchange server for the mail application.

I think I may be missing something here in your instructions:

'Then execute the mail merge that you want to send out by email with the
attachments and with the result of execution of that mail merge on the
screen,'

I have the mail merge document on the screen and have the first record
fields showing (I tried running this showing different record sets as well
with the same result) - I go to run the macro and select the directory merge
I created as stated earlier in the instructions. The email merge runs fine.
But I check the resultant emails sent / received and only the first email in
the list has the correct fields merged - all others are blank.

Any suggestions? Is there something different with Word 2003 to cause this?

AS
 
D

Doug Robbins - Word MVP

Is it the mailmerge main document that you have on the screen when you run
the macro or have you executed the mailmerge to a new document and then it
is with that document on the screen that you should run the macro.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
M

Matt B

AS,

I really appriciate the work Doug put into this macro and finally finding
this post in this community. I did however encounter the same problems as
you. I'm using Word 2003 and Outlook 2003. I'm not sure if the solution I
used will work for you (maybe Doug can comment on it) but it worked for me.
I modified the code a little. I think the problem is that the code calls for
the macro to "Cut" the email in order to paste it to the new doc. In the
code after the line:

While Counter <= Maillist.Tables(1).Rows.count

if you change the line that reads:

Source.Sections.First.Range.Cut

to

Source.Sections.First.Range.Copy

the macro will stop pasting blank pages after the first. In addition I had
to add another line to force the Sorce file to go to the next record. I
added the line:

Source.MailMerge.DataSource.ActiveRecord = wdNextRecord

to the macro just after the statement:

Counter = counter + 1.

I executed the mail merge of the form letter so that it was positioned on
the first record then I executed the macro.

Hope this helps.
 
D

Doug Robbins

The reason that you had to make these changes is because you did NOT execute
the mailmerge that creates the text for the body of the email messages to a
new document and then run the macro with that document as the active
document.

What you have done is execute the macro with the mailmerge results being
previewed in the mailmerge main document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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