Move data from ACCESS to word via VBA

jpl458

Well-known member
Local time
Today, 11:03
Joined
Mar 30, 2012
Messages
1,218
I have an ACCESS database that has a join query that contains data that I need to insert into a Word document (name, address city etc.) and do that with VBA. I have unsophisticated users, so I don't want them to have to fill out the menus normally used. I need to have it automated. Is such a method possible and are there any examples that anyone knows of? I have trolled the web and YouTube and can't find what I need. Sorry for not having any code to show, but I am trying to figure out how/if it can be done.

Thanks
 
It's called Mail Merge. Try searching under that term. There should be a lot of discussions and examples. Look for one posted by Albert Kallal in particular, which is reportedly very appropriate.
 
I have a strong dislike for MailMerge so I always use OLE automation. It is much more flexible. Here's a very basic sample using hard-coded bookmarks. I have production applications that manage thousands of documents because they use mapping tables to connect table data with bookmarks. The users get to create new documents with bookmarks. Then they get to link the bookmarks with the data that fills them, all without any programming support.

If you have only a couple of documents, this method will work well enough for you. I'm actually working on a sample that has the mapping but it is not done yet. Watch for it in the database samples or PM me if you want me to describe how to fill the bookmarks with table data instead of hard-coding.

 
I have a strong dislike for MailMerge so I always use OLE automation. It is much more flexible. Here's a very basic sample using hard-coded bookmarks. I have production applications that manage thousands of documents because they use mapping tables to connect table data with bookmarks. The users get to create new documents with bookmarks. Then they get to link the bookmarks with the data that fills them, all without any programming support.

If you have only a couple of documents, this method will work well enough for you. I'm actually working on a sample that has the mapping but it is not done yet. Watch for it in the database samples or PM me if you want me to describe how to fill the bookmarks with table data instead of hard-coding.

In general I'd agree that Automation is more powerful and flexible. However, Mail Merge is probably more easily grasped by less experienced Access citizen developers.
 
It may be more easily grasped by less experienced developers but I could never make it work in the real world:( I look at it the way I look at macros - if you know how to program, these things just seem bizarre in how they operate.
 
I have a strong dislike for MailMerge so I always use OLE automation. It is much more flexible. Here's a very basic sample using hard-coded bookmarks. I have production applications that manage thousands of documents because they use mapping tables to connect table data with bookmarks. The users get to create new documents with bookmarks. Then they get to link the bookmarks with the data that fills them, all without any programming support.

If you have only a couple of documents, this method will work well enough for you. I'm actually working on a sample that has the mapping but it is not done yet. Watch for it in the database samples or PM me if you want me to describe how to fill the bookmarks with table data instead of hard-coding.

Know what I'll be doing today. I thought mail merge was cumbersome. I'm on windows 10 with Office 365, anything I need to change up front?

Thanks again, Pat.
 
The sample is designed to work with older applications so it will work fine with newer ones. You might have to fix up the references though f your's happen to be older than mine.
 
All mine is Current. I 'm pretty sure with an Office subscription updates are automatic. I just looked it and it updates in the background.
I downloaded and set up your examples. Now I have wade through them.

Thanks Again
 
I'm working on a more sophisticated example that uses tables to populate the word documents. I've uploaded the schema with a description of how the tables are used. No promises on when I might finish this though so don't hold your breath. The sample you have will be fine for a couple of documents.
 

Attachments

I'm working on a more sophisticated example that uses tables to populate the word documents. I've uploaded the schema with a description of how the tables are used. No promises on when I might finish this though so don't hold your breath. The sample you have will be fine for a couple of documents.
I have 6 documents only. Thanks for the example.
 
Posted a week ago

 

Users who are viewing this thread

Back
Top Bottom