partially automate mailmerge to email

C

christophe

HI,

I've setup a mailmerge document with a dbase table.
this table also contains an email adres.
Is there an easy way to already fill in the email in
the form which popups when hitting the button
"Merge to email" and also already choose "attachement" ?


kind regards
christophe
 
D

Doug Robbins - Word MVP

Use the following code in a macro, substituting the relevant field name for
the email addresses:

With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.MailAddressFieldName = "Email"
.MailAsAttachment = True
.Execute
End With


--
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
 
C

christophe

Thanks a lot Doug Robbins,

It works perfect, only I get an error 5661
on the Execute line.
Because I don't need it, I've deleted it.
For me, when the proper values are already filled
in, that is more than enough.
The user will choose to click send or not.

One further question
can that macro automatically be done while opening
the doc.
Because know I've attached the macro to a button.
but I prefer to do it when the doc is opened ?

Thanks in advance
Kind Regards
christophe
 
D

Doug Robbins - Word MVP

That would necessitate you having:

1. The data source already attached to the document

2. The macro in the document.

Having the macro in the document will require that you respond to the Enable
macros in the document dialog box, so you are hardly gaining anything over
clicking on a button on a toolbar.

To prevent an error occuring if you were to click on the button when the
document was not a mailmerge main document with an attached datasource, you
probably should use:

With ActiveDocument
If .MailMerge.State = wdMainAndDataSource Then
.Destination = wdSendToEmail
.MailAddressFieldName = "Email"
.MailAsAttachment = True
End If
End With


--
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