By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 2,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

mail merge to word

P: n/a
hello,

i am perfoming a mail merge with the following code.

Public Function MergeIt()
Dim objWord As Object
Set objWord = GetObject("C:\MyMerge.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the db3 database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Rapid Motion\Client " & _
"Info\Accident Claims UK\db3.mdb", _
LinkToSource:=True, _
Connection:="TABLE tblsolicitordetails", _
SQLStatement:="SELECT * FROM [tblsolicitordetails]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function

the first time i execute it, it fails because the word document does
not have the merge fields in place.

So i open the word document myMerge then set up the merge fields and
save it.

the second time i open it 2 instances of Word open, 1 with my merged
fields and all the merge options, and another that simply shows the
values of the merged fields and no merge options.

Why does this happen?

Aaron
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Aaron" <aa***@rapid-motion.co.uk> wrote in message
news:26**************************@posting.google.c om...
hello,

i am perfoming a mail merge with the following code.

Public Function MergeIt()
Dim objWord As Object
Set objWord = GetObject("C:\MyMerge.doc", "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the db3 database.
objWord.MailMerge.OpenDataSource _
Name:="C:\Rapid Motion\Client " & _
"Info\Accident Claims UK\db3.mdb", _
LinkToSource:=True, _
Connection:="TABLE tblsolicitordetails", _
SQLStatement:="SELECT * FROM [tblsolicitordetails]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function

the first time i execute it, it fails because the word document does
not have the merge fields in place.

So i open the word document myMerge then set up the merge fields and
save it.

the second time i open it 2 instances of Word open, 1 with my merged
fields and all the merge options, and another that simply shows the
values of the merged fields and no merge options.

Why does this happen?

Aaron
Your code includes a ' Execute the mail merge.
objWord.MailMerge.Execute


so the merge is executed and the output is made..

Where did you want it to go?
I think the default is to 'merge to a new document'
there is probably an argument for the others (printer or email) but having
not experiemented with these I can't help you with what they might be.

Mal.
Nov 13 '05 #2

P: n/a
Hum, I am going to suggest that you give my sample word merge a try. It
should work for you.

You can read the notes on how/why I fixed problems like the 2nd copy of
ms-access being launched, and also issues of security.

no need to re-invent the wheel here. Check out the word merge at:
http://www.attcanada.net/~kallal.msn.../msaccess.html
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.