A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

mailmerge from access 2007 to word 2007



 
 
Thread Tools Display Modes
  #1  
Old July 14th, 2009, 02:20 PM posted to microsoft.public.access
Licinio
external usenet poster
 
Posts: 3
Default 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  
Old July 14th, 2009, 03:55 PM posted to microsoft.public.access
Mark Andrews[_2_]
external usenet poster
 
Posts: 600
Default 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  
Old July 15th, 2009, 08:06 AM posted to microsoft.public.access
Licinio
external usenet poster
 
Posts: 3
Default 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  
Old July 16th, 2009, 03:02 PM posted to microsoft.public.access
Mark Andrews[_2_]
external usenet poster
 
Posts: 600
Default 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  
Old July 30th, 2009, 02:02 PM posted to microsoft.public.access
Licinio
external usenet poster
 
Posts: 3
Default 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  
Old August 12th, 2009, 01:47 PM posted to microsoft.public.access
Mark Andrews[_2_]
external usenet poster
 
Posts: 600
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.