473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Mail Merge Access -> Word ( Office 2003)

So, I have a nice little query, and it produces nice pretty results, which are even the ones I wanted for once.
The plan is to plug these into a word mailmerge. Simple theory.
Problem is I can't get the stupid thing to let me set up mail merge with a query recordset rather than a normal table.
So, thats the basic question, how do I do that
Also, if anyones a VBA god/goddess and would like to inform me of a way to make it do the setup thing automatically rather than trying to train my users to use the wizard, that'd be great
Cheers
Aug 20 '07 #1
1 1316
puppydogbuddy
1,923 Expert 1GB
So, I have a nice little query, and it produces nice pretty results, which are even the ones I wanted for once.
The plan is to plug these into a word mailmerge. Simple theory.
Problem is I can't get the stupid thing to let me set up mail merge with a query recordset rather than a normal table.
So, thats the basic question, how do I do that
Also, if anyones a VBA god/goddess and would like to inform me of a way to make it do the setup thing automatically rather than trying to train my users to use the wizard, that'd be great
Cheers
Here is the code for an automated mail merge through Access that demos using a query as the data source. This code is from the tips page of www.aadconsulting.com

Run A Word MailMerge from Access

Copy and paste into a new Access module:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Function MergeIt(stFilePath As String, stQuery As String)
  4. Paramaters:
  5. stFilePath As String - Full path to merge letter template
  6. stQuery As String - SQL String for merge fields data from the CurrentDB
  7.  
  8. Dim stDBName As String
  9. Dim objWord As Word.Document
  10. Dim stSQL As String
  11.  
  12. stSQL = "Select * from " & stQuery & ""
  13. stQuery = "QUERY " & stQuery
  14.  
  15. stDBName = CurrentDb.Name
  16.  
  17. Set objWord = GetObject(stFilePath, "Word.Document")
  18.  
  19. ' Make Word visible.
  20. objWord.Application.Visible = True
  21.  
  22. ' Set the mail merge data source as the Northwind database
  23. objWord.MailMerge.OpenDataSource _
  24. Name:=stDBName, _
  25. LinkToSource:=True, _
  26. Connection:=stQuery, _
  27. SQLStatement:=stSQL
  28.  
  29. ' Execute the mail merge.
  30. objWord.MailMerge.Execute
  31.  
  32. End Function
  33.  
Sep 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: antonovaCCCS | last post by:
In our old VB 6 application we utilize a mail merge feature of Word 97 with MS Access. A table in Access is populated from VB and a Word template is wired to that table. So all we do in the code is...
1
by: Aaron | last post by:
Hi People, Does anyone know how to start a mail merge with ms access to ms word? At the moment i select the records i wish to merge with a query, get the results, then select Office Links from...
9
by: Neil Ginsberg | last post by:
I have a strange situation using Access to automate a Word mail merge. Using Access 2000 and Word 2000, the code opens Word, opens the document in Word, sets a table in the calling Access...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
0
by: Linda Cacina | last post by:
Hello all you fine folks, Here is some code I am using to merge data from a single record Access 2K3 table into a NEW word document based on a pre-defined Word merge template doc. All I want to...
15
by: sparks | last post by:
They are wanting to use word to print out some cards 4 to a page preformatted stuff from an access database. the problem with this is they don't want to do the same card twice. How can setup a...
0
by: Darragh | last post by:
I'm encountering some serious problems trying to set Access 2000 querys (parameters and views) as data sources for my mail merge documents (Word 2003). After spending hours scouring the web for...
2
by: buz | last post by:
I have a database that was built using Office 97 version and would like to update a more current platform. This program runs on a server and the enduser runs the program from thier desktop. Windows...
7
by: jolaunt | last post by:
I have a database with a query running a make table and linked to a mail merge letter. I have a button with the following code: Private Sub Command464_Click() Dim LWordDoc As String Dim oApp...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.