Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2013, 01:08 AM
MHutcheson MHutcheson is offline Dynamic Subject Email Merge Windows 7 64bit Dynamic Subject Email Merge Office 2010 32bit
Novice
Dynamic Subject Email Merge
 
Join Date: Oct 2013
Posts: 1
MHutcheson is on a distinguished road
Default Dynamic Subject Email Merge

I have a Word 2010 document linked to an Access 2010 data source. When a user clicks a button in Access, the Word document loads and performs a email merge using the below VBA code:

Private Sub Document_Open()
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
.MailSubject = "Your Refund " & ActiveDocument.MailMerge.DataSource.DataFields("Re turn_code").Value
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord

End With
.Execute Pause:=False
End With


End Sub

However, as the .mailsubject part is not in the loop it is only retrieving the first Return Code. I have tried to integrate in the loop to no avail using this code:

Dim i As Integer
Private Sub Document_Open()
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord

i = .DataSource.DataFields.Count

Do While i > 0
.MailSubject = "Your Refund " & ActiveDocument.MailMerge.DataSource.DataFields("Re turn_code").Value
i = i - 1
Loop

End With
End With
End Sub

But keep receiving the message the data member (.DataSource) is not found.

Thank you for any help.

Regards,

Michael
Reply With Quote
Reply

Tags
access 2010, vba, word 2010

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Subject Email Merge Mail Merge Into Dynamic Table Jag618 Mail Merge 1 03-04-2013 11:26 PM
Dynamic Subject Email Merge merge to excel in dynamic location mjlaw Mail Merge 1 03-22-2012 11:16 PM
Dynamic Subject Email Merge email as pdf attachment - subject line and attachment named after mail merge Nexus Mail Merge 12 04-13-2011 11:34 PM
Mail merge with customised subject mohanss Mail Merge 0 06-26-2010 10:14 AM
Dynamic Subject Email Merge getting additional characters in email subject line namishtiwari Outlook 1 04-21-2009 11:21 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:52 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft