mailmerge from access 2007 to word 2007

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.
 
L

Licinio

I can't find any relevant article on Albert's site... Did you see
anything in particular concerning mailmerge? Thanks.
 
L

Licinio

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?
 
M

Mark Andrews

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top