L
Licinio
Hello, I need to generate letters from a query with parameters.
I have found sample code, but keep bumping into lots of confusing
messages (the task is taking longer that expected, the database has
been placed by user x in a state that does not allow to open or block
it, Word could not re-establish a DDE connection to Microsoft
Access,...) and the mailmerge does not work.
Here is the code I am using and I'm asking you how I can set it right:
Set objWord = GetObject("T:\xxx\xxx.docx", "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource Name:="", LinktoSource:=True,
Connection:="QUERY q_xxx"
'objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
'objWord.Application.Documents(2).Close wdDoNotSaveChanges
Notes:
xxx stands for file or folder names;
after all the error messages, a new db windows eventually opens;
The query gets its parameter from a form that is open when launching
the code.
I have found sample code, but keep bumping into lots of confusing
messages (the task is taking longer that expected, the database has
been placed by user x in a state that does not allow to open or block
it, Word could not re-establish a DDE connection to Microsoft
Access,...) and the mailmerge does not work.
Here is the code I am using and I'm asking you how I can set it right:
Set objWord = GetObject("T:\xxx\xxx.docx", "Word.Document")
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource Name:="", LinktoSource:=True,
Connection:="QUERY q_xxx"
'objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
'objWord.Application.Documents(2).Close wdDoNotSaveChanges
Notes:
xxx stands for file or folder names;
after all the error messages, a new db windows eventually opens;
The query gets its parameter from a form that is open when launching
the code.