Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging a Access Query with a Word Document

Status
Not open for further replies.

Scudy

Programmer
Feb 26, 2004
2
GB
Hello

I am trying to get a query to do a mail merge with Word automatically by clicking a button on my switchboard, rather than having to do it manually through the "Merge with word" function on the menu bar.

can any one help me?

Thanks
 
Record the mail merge steps with the macro recorder...


then you can add edits to the code
 
how do i record a macro in access though?
 
And what about DoCmd.DoMenuItem ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
You do the merge from within word, connecting to an access query or table...


Tools>mail merge...follow the wizard
 
I have a similar question as Scudy. Is there a way to open word mail merge document from an access form and populate the merge fields with data from the form? I am using Access 97 and I don't have a "merge with Word" menu item

 
Officeguru..

I have a db form with a button on it that launches a word doc., prints a (mail merged) form letter base on the data in the active access form, prints the letter, closes word and returns control to access.

...is that what your looking for?

 
I am looking for this exactly, although I am not the original poster.
 
ETID,

I think that is exactly what I am looking for, can you please show me how it's done?
 
Build a make table query that pulls only one record based on the active form, FROM THE TABLES THAT ARE USED IN THE ACTIVE FORM, (use the build option in the criteria area for each field needed to filter the new table down to the active record in the form, and point them to the coressponding form field)



then add a button to the form

'----------------------------------------------------
'THIS CODE GOES IN THE ON CLICK EVENT FOR THE BUTTON ON THE FORM

DoCmd.SetWarnings False
DoCmd.OpenQuery "make_table_MERGED_Letter_data_2004", acViewNormal, acReadOnly
DoCmd.SetWarnings True



DocName="C:\MONTHLY_LETTERS\CUSTOMER_STATUS.DOC"
SHELL ("""C:\Program Files\Microsoft Office\Office10\winword.exe"" """ & DocName & """")

'----------------------------------------------------


'THIS CODE GOES INTO THE ON OPEN EVENT OF THE CUSTOMER_STATUS.DOC


Private Sub Document_Open()

AppActivate ("CUSTOMER_") 'SET WINDOWS FOCUS TO THE WORD APP.
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord

AppActivate ("CUSTOMER_")

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0

ActiveDocument.Saved = True 'BYPASSES THE SAVE DOC PROMPT

Application.Quit

End Sub
 
Oooops...forgot one step,

You also have to merge your word doc to the table that is created by the make table query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top