Mailmerge from Access 2003 - Word 2010

anthonys

Registered User.
Local time
Today, 21:35
Joined
Feb 4, 2005
Messages
40
Hi

I have a legacy system that i wrote a few years ago that worked fine with office 2003 but we are planning an upgrade to office 2010. The application included a emailmerge button that performed a word mailmerge in the background. With office 2010 the code just steps through not appearing to do anything. I have the word 14 reference ticked and the basics of the code is below.

FYI the app will still use Access 2003 due to license issues.....

Any ideas? Has the word object model changed?


Thanks - Ant


dim obj as word.application
dim strEmailSubject as string

Set obj = CreateObject("Word.Application")


'now we open and execute the email merge in word
obj.Documents.Open strDocLocation

Set doc = obj.ActiveDocument
strEmailSubject = InputBox("Please Type Email Subject Line.", "Email Subject Line....")

doc.MailMerge.OpenDataSource strDataSource
doc.MailMerge.MailSubject = strEmailSubject
doc.MailMerge.MailFormat = wdMailFormatHTML
doc.MailMerge.MailAddressFieldName = "App_Email"
doc.MailMerge.Destination = wdSendToEmail
doc.MailMerge.Execute
 
Access 2003 has no concept of Office 2010 products.

Remove the reference and go with LATE binding:

Code:
[COLOR=black]dim obj as [/COLOR][COLOR=red][B]Object[/B][/COLOR]
[COLOR=black]dim strEmailSubject as string

Set obj = CreateObject("Word.Application")


'now we open and execute the [/COLOR][URL="http://www.access-programmers.co.uk/forums/showthread.php?t=201731#"][COLOR=black]email[/COLOR][/URL][COLOR=black] merge in word
obj.Documents.Open strDocLocation

Set doc = obj.ActiveDocument
strEmailSubject = InputBox("Please Type Email Subject Line.", "Email Subject Line....")

doc.MailMerge.OpenDataSource strDataSource
doc.MailMerge.MailSubject = strEmailSubject
doc.MailMerge.MailFormat = wdMailFormatHTML
doc.MailMerge.MailAddressFieldName = "App_Email"
doc.MailMerge.Destination = wdSendToEmail
doc.MailMerge.Execute
[/COLOR]

Now just a note - You can't use the newer file formats for this. So you can't use docx for example. You need to stay with the format that Access 2003 knows about which is .doc.
 
Thanks for the tip but it is still not actioning the code, it steps through with no errors but word is not not opening and the mailmerge is not sending the email. Any other tips, it's bugging the hell out of me!!
 
Having looked at it some more i think it might be caused by 'Protected View' when the template opens.

Does anyone know how to switch on 'enable editing' from code?

cheers ant!
 
OK - after much hair pulling it turned out the issue is caused by the installation of 2003 runtime or 2003 full access. I had to uninstall office 2010 and reinstall it.
 

Users who are viewing this thread

Back
Top Bottom