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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
mailmerge from access 2007 to word 2007
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. |
#2
|
|||
|
|||
mailmerge from access 2007 to word 2007
Just use the word merge code found on Albert's site:
http://www.members.shaw.ca/AlbertKallal/ Mark RPT Software http://www.rptsoftware.com "Licinio" wrote in message ... 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. |
#3
|
|||
|
|||
mailmerge from access 2007 to word 2007
I can't find any relevant article on Albert's site... Did you see
anything in particular concerning mailmerge? Thanks. |
#4
|
|||
|
|||
mailmerge from access 2007 to word 2007
Looks like it is on the bottom link on the page:
http://www.members.shaw.ca/AlbertKal.../msaccess.html "Licinio" wrote in message ... I can't find any relevant article on Albert's site... Did you see anything in particular concerning mailmerge? Thanks. |
#5
|
|||
|
|||
mailmerge from access 2007 to word 2007
I haven't been able to make that code work, but I've come up with an
alternative solution which is also not working (!), but hopefully is easier to set right. In a form I have written the following code to open a saved mailmerge document in MSWord: Set WordApp = CreateObject("Word.Application") Set objWord = GetObject(strpath, "Word.Document") objWord.Application.Visible = True That file is a mailmerge document linked to the parameter query, and the parameter is contained in the form itself. However this doesn't seem to work. I get a message saying that the task is taking longer than expected, and if I choose not to wait, the document opens prompting me to insert the paramter. If I insert it, a new instance of the database is opened. Do you have any idea of how I could make it work? |
#6
|
|||
|
|||
mailmerge from access 2007 to word 2007
I would stick with Albert's code. I use it all the time and think it's the
best way to do word merging. Try a bit more and if you can't get it to work try posting another topic asking for albert's help with word merge (he answers some of these posts). You could checkout a product I sell for email merges, it has the word merge code included: http://www.rptsoftware.com/products/email/ if my demo does word merge on your computer than you should be able to use Albert's code. Mark "Licinio" wrote in message ... I haven't been able to make that code work, but I've come up with an alternative solution which is also not working (!), but hopefully is easier to set right. In a form I have written the following code to open a saved mailmerge document in MSWord: Set WordApp = CreateObject("Word.Application") Set objWord = GetObject(strpath, "Word.Document") objWord.Application.Visible = True That file is a mailmerge document linked to the parameter query, and the parameter is contained in the form itself. However this doesn't seem to work. I get a message saying that the task is taking longer than expected, and if I choose not to wait, the document opens prompting me to insert the paramter. If I insert it, a new instance of the database is opened. Do you have any idea of how I could make it work? |
Thread Tools | |
Display Modes | |
|
|