View Single Post
  #3   Report Post  
KiwiRyu KiwiRyu is offline
Junior Member
 
Posts: 1
Default

Hi Peter,

I appreciate this post is quite old now so you may not be around BUT, just in case, I hope you can help me out.

I am looking to run a mail merge with unique subject lines for each individual email in the merge. Your code looked to be perfect, but when I try it I get the following error:

"Complie error:

Method or data member not found"

I am using Office 2007

Any help you can provide would be most appreciated.

Quote:
Originally Posted by Peter Jamieson View Post
You can try the approach I just posted in reply to someone else.

If you are familiar with VBA, you can use Word's MailMerge events and
VBA to specify the subject for each email.
e.g. in the VBA Editor, Insert a new Class Module, name it
EventClassModule, and insert the following code:

Public WithEvents App As Word.Application
Private Sub App_MailMergeBeforeRecordMerge( _
ByVal Doc As Document, _
Cancel As Boolean)
' set this to be the exact name
' of the field you want to use
' (uppercase/lowercase are
' significant here)
Const strSubjectFieldName = "mysubjectfield"
Doc.MailMerge.MailSubject = _
Doc.MailMerge.DataSource.DataFields(strSubjectFiel dName).Value
End Sub

In an ordinary module, put the following VBA
'---
Dim x As New EventClassModule
Sub MergeWithEvents()
EnableEventHandler
' Do the merge
ActiveDocument.MailMerge.Execute Pause:=False
' The events fire for all documents
' so disable them
DisableEventHandler
End Sub

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

Sub DisableEventHandler()
Set x.App = Nothing
End Sub


Peter Jamieson

http://tips.pjmsn.me.uk

On 24/02/2010 18:08, Kiran wrote:
Hi,

I need to use mail merge to send multiple e-mails to different individuals
for which subject line needs to be pulled from a excel column.My excel file
name is sample.xlsx. The data in the sheet is as below, the issue column
would be the source for subject.Request assistance in getting this through
Loan Title_Officer Issue
1 Document not prepared
2
Not Invoiced