M
mikelee101
Hello,
I'm trying to do a merge to email, but would like the subject line of
the email to contain a mergefield. Per the mailmerge forum, this
isn't supported, but may be possible through VBA. What I'd like is
for the subject line to be:
Important information regarding <<domain>>.
I have Word2003, and am somewhat proficient in Excel VBA, but have
little to no experience with Word. The document itself looks ok, and
I can scroll through the recipients.
I found the MailMerge object, but am not having any success with it.
Here's what I tried:
Sub TestMerge()
Dim MgDoc As Document
Set MgDoc = Application.Documents("Notification.doc")
MgDoc.MailMerge.MailAddressFieldName = "email address"
MgDoc.MailMerge.MailSubject = "Important Information Regarding" &
"domain"
MgDoc.MailMerge.Destination = wdSendToEmail
MgDoc.MailMerge.MailAsAttachment = False
MgDoc.MailMerge.Execute
End Sub
However, after the execute statement, I get an error that says:
Word cannot merge documents that can be distributed by mail or fax
without a valid mail address. Choose the Setup button to select a mail
address data field.
So...any thoughts? What "Setup button" is it talking about? I can
scroll through the recipients in Word, so I know it knows that they're
there. Also, I can't imagine that the line that should set the
mailsubject field will be able to tell the difference between text
"Important Information Regarding" and the mailmerge field "domain."
If anyone knows if I can reference a merge field in the mailsubject
property and, if so, what's causing the run-time error, I'd really
appreciate the help.
Thanks,
Mike Lee
Coppell, TX, USA
I'm trying to do a merge to email, but would like the subject line of
the email to contain a mergefield. Per the mailmerge forum, this
isn't supported, but may be possible through VBA. What I'd like is
for the subject line to be:
Important information regarding <<domain>>.
I have Word2003, and am somewhat proficient in Excel VBA, but have
little to no experience with Word. The document itself looks ok, and
I can scroll through the recipients.
I found the MailMerge object, but am not having any success with it.
Here's what I tried:
Sub TestMerge()
Dim MgDoc As Document
Set MgDoc = Application.Documents("Notification.doc")
MgDoc.MailMerge.MailAddressFieldName = "email address"
MgDoc.MailMerge.MailSubject = "Important Information Regarding" &
"domain"
MgDoc.MailMerge.Destination = wdSendToEmail
MgDoc.MailMerge.MailAsAttachment = False
MgDoc.MailMerge.Execute
End Sub
However, after the execute statement, I get an error that says:
Word cannot merge documents that can be distributed by mail or fax
without a valid mail address. Choose the Setup button to select a mail
address data field.
So...any thoughts? What "Setup button" is it talking about? I can
scroll through the recipients in Word, so I know it knows that they're
there. Also, I can't imagine that the line that should set the
mailsubject field will be able to tell the difference between text
"Important Information Regarding" and the mailmerge field "domain."
If anyone knows if I can reference a merge field in the mailsubject
property and, if so, what's causing the run-time error, I'd really
appreciate the help.
Thanks,
Mike Lee
Coppell, TX, USA