((no subject))

S

SMR

I am using Office 2003 and email merge via word. I would like to be able to insert a subject into the emails that I am sending. Seems like it would be simple but after an hour of trying I need some assistance. Please help me!

***please pardon the previous blank post***
 
P

Peter Jamieson

As far as I know the only way you can do it is to use VBA Mailmerge events
to specify the subject for each record. e.g....

The overview is as follows:
a. In the document, you have a class module with a routine that
responds to the Mailmerge "Before Record Merge" event. This routine will
modify the Subject using a field in the data source.
c. Also in the document, you have a module with an AutoOpen routine that
creates an instance of your class and initialises event handling.

I haven't actually tested this particular code, and I'm not a VBA expert so
please don't regard the code as "polished" even if it works - you may need
to add error handling and so on.

So...

1. Create a new document, connect it to your data source, and insert one
merge field so you can test the merge.

2. Open up the VBA Editor and
a. insert a class module.
b. name it EventClassModule in the properties box
c. Copy the following code into the module:

Public WithEvents App As Word.Application

Private Sub App_MailMergeBeforeRecordMerge(BYVal Doc As Document, Cancel As
Boolean)

' Set the Mailmerge subject to the value in
' a field in your data source. For the example,
' let's say the field is called emailsubject. But
' you could construct any subject you liked.

Doc.MailMerge.MailSubject = _
Doc.MailMerge.DataSource.DataFields("emailsubject")

End Sub

3. Insert an ordinary module (the name does not matter) and insert the
following code:

Dim x As New EventClassModule

Sub autoopen()
Set x.App = Word.Application
End Sub

4. Save and close the document. Open it to trigger the autoopen, then
perform a test merge.

NB, if you start changing the code you may find that you need to re-run your
autoopen code again, and/or save/close/open the document.

--
Peter Jamieson
MS Word MVP

SMR said:
I am using Office 2003 and email merge via word. I would like to be able
to insert a subject into the emails that I am sending. Seems like it would
be simple but after an hour of trying I need some assistance. Please help
me!
 

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