WORD merge with command button

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

Hi,

I have several queries that I would like to merge with
Word documents using a command button on a form. Is this
possible? In checking other posting, I found mention of
this, but no clues on how to do it. I want the user to
just click on the button and get the merged word document
in Word.

Any help would be appreciated.

Thanks,
Phil
 
Hi Phil,

These links will get you started (especially, perhaps, the first):

Albert Kallal's sample mailmerge application:
http://www.attcanada.net/~kallal.msn/wordmerge/index.html

Q209976 ACC2000: Using Automation to Run Word Mail Merge from Access
http://support.microsoft.com/?kbid=209976

Q209882 ACC2000: Using Automation to Create a Word 2000 Merge Document
http://support.microsoft.com/?kbid=209882

http://word.mvps.org/faqs/MailMerge/index.htm

http://word.mvps.org/faqs/interdev/GetDataFromDB.htm
 
From Phil to Phil

I done a lot of research on this item and here is the best solution I've
come up with.

I have a form with a text box where the user enters the Word document name
and a command button which has the following code in the on-click event.

' my word documents are all in directory c:\Mailing List
' [Report Menu] is the form name with the text box and command button
' [MergeFile] is the text box with the word document name

Set objWord = GetObject("c:\Mailing List\" & Forms![Report
Menu]![MergeFile] & ".doc", "Word.Document")

' Make Word visible.
objWord.Application.Visible = True

' Set the mail merge data source as Mailing List.mdb
' my Access file is Mailing List.mdb
' Query is MailMergeEvent

objWord.MailMerge.OpenDataSource _
Name:="c:\Mailing List\Mailing list.mdb", _
LinkToSource:=True, _
Connection:="QUERY MailMergeEvent", _
SQLStatement:="SELECT * FROM [MailMergeEvent]"
' SQLStatement:="SELECT Last_Name, First_Name, Organization, Address_1,
City, State, Zip FROM [MailMergeEvent]"

' be careful of the line wrap.....

I'm using Windows 98 and Access 2000 and it works fine. The word document
opens and then you click on "merge" or the merge icon. I tried to run my
db on a XP computer using Access 2003 and it only works if you open the form
and then go into design view and then back to regular view. I don't know
why. I'm posting this problem to the newsgroup in hopes of help.

Good luck
 
Back
Top