A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Custom Subject Line from Excel Data



 
 
Thread Tools Display Modes
  #1  
Old February 24th, 2010, 06:08 PM posted to microsoft.public.word.mailmerge.fields
kiran
external usenet poster
 
Posts: 94
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  
Old February 24th, 2010, 06:44 PM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.