Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Kiran Kiran is offline
external usenet poster
 
Posts: 6
Default Custom Subject Line from Excel Data

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

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Custom Subject Line from Excel Data

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

  #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
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge Subject Line Tom Ventouris Mailmerge 3 February 24th 10 11:12 AM
How do I locate attachment in line under subject? [email protected] Microsoft Word Help 2 January 4th 10 06:24 PM
How do I add a subject line to my Word email merge? Stephanie Microsoft Word Help 1 May 29th 08 06:07 AM
Attached file below the subject line and not the text box cac Microsoft Word Help 1 January 26th 06 01:31 AM
Unique Subject Line Sam Mailmerge 0 January 20th 05 07:59 AM


All times are GMT +1. The time now is 11:02 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"