OT ? - How to stuff Access data into existing Word template

  • Thread starter Thread starter Marcus
  • Start date Start date
M

Marcus

Hy there,
I've read about mailmerge capabilities but what I'm looking for is a VBA
programming way, given a selected row on a form to:
- launch Word, open a new document using a given template
- fill in the new document data coming from the current row into word's
document fields

Could be handy to select data from a SQL server and stuff into the word
document fields from the query.

Regards
 
Marcus

One approach would be to use Access/VBA to:
1) dynamically create/run a query that returns the data you wish
2) export that query/results to a Word Merge/text file
3) open a Word merge document that looks to the Word Merge/text file for
its data

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 
Jeff Boyce said:
Marcus

One approach would be to use Access/VBA to:
1) dynamically create/run a query that returns the data you wish
2) export that query/results to a Word Merge/text file
3) open a Word merge document that looks to the Word Merge/text file for
its data

--

Any code sample?
 
yes, I have a working example that merges the CURRENT record from any form
you have, and does it with ONE LINE of code
you place behind a button...


It also has the ability to set the output merge doc name, and even print the
doc it if you wish....

You can find this "super easy word merge" example here:

http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html

make sure you read the additional notes for the advanced features like
printing, or setting your own sql....
 
Albert D. Kallal said:
yes, I have a working example that merges the CURRENT record from any form
you have, and does it with ONE LINE of code
you place behind a button...

Hi there Albert, I've been a bit busy so I've just started testing your
code.

Unfortunatelly I'm getting a compile error in WordCode module, particullarly
on the line

Dim OneField As DAO.Field

The error is due to a DAO reference

As I'm using ADO I've skipped the reference to dao 3.x as stated.

Is there a way to fix the problem without screwing up the code you've
prepared?

Regards

Marcus
 
Back
Top