Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 02:30 AM
Aaron
Guest
 
Posts: n/a
Default mail merge to word

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
  #2  
Old November 13th, 2005, 02:31 AM
Mal Reeve
Guest
 
Posts: n/a
Default Re: mail merge to word


"Aaron" <aaron@rapid-motion.co.uk> wrote in message
news:260d7f40.0408011240.654a5cdc@posting.google.c om...[color=blue]
> 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[/color]

Your code includes a[color=blue]
> ' Execute the mail merge.
> objWord.MailMerge.Execute[/color]

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.


  #3  
Old November 13th, 2005, 02:32 AM
Albert D. Kallal
Guest
 
Posts: n/a
Default Re: mail merge to word

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
pleaseNOOSpamKallal@msn.com
http://www.attcanada.net/~kallal.msn


 

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles