Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / November 2003

Tip: Looking for answers? Try searching our database.

((no subject))

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SMR - 12 Nov 2003 21:46 GMT
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***
Peter Jamieson - 12 Nov 2003 23:52 GMT
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

> 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***
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.