I have created a module to automate a mail merge form access. I used the following code from the MS support site:
Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\MyMerge.doc", "Word.Document")
' Make Word Visible.
objWord.Application.Visible = True
' Set the Mail Merge data Source.
objWord.MailMerge.OpenDataSource Name:="c:\CHC.MDB", LinkToSource:=True, Connection:="TABLE tblCustomers", SQLStatement:="Select * from [tblCustomers]"
' Execute the Mail Merge.
objWord.MailMerge.Execute
End Function
I have triple checked the code and it is same as MS code.
I am getting an error message saying C:\CHC.MDB doesn't exist, but it does!
I have tried renaming it, some friends have had a look and can't see anything wrong other than the MS dos name is different than CHC.MDB (it is CHCMDB~1.MDB) I don't know if this makes any difference.
Any help gratefully received.
Russ
Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\MyMerge.doc", "Word.Document")
' Make Word Visible.
objWord.Application.Visible = True
' Set the Mail Merge data Source.
objWord.MailMerge.OpenDataSource Name:="c:\CHC.MDB", LinkToSource:=True, Connection:="TABLE tblCustomers", SQLStatement:="Select * from [tblCustomers]"
' Execute the Mail Merge.
objWord.MailMerge.Execute
End Function
I have triple checked the code and it is same as MS code.
I am getting an error message saying C:\CHC.MDB doesn't exist, but it does!
I have tried renaming it, some friends have had a look and can't see anything wrong other than the MS dos name is different than CHC.MDB (it is CHCMDB~1.MDB) I don't know if this makes any difference.
Any help gratefully received.
Russ