Move data from ACCESS to word via VBA (1 Viewer)

jpl458

Well-known member
Local time
Today, 00:21
Joined
Mar 30, 2012
Messages
1,038
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
 

GPGeorge

Grover Park George
Local time
Today, 00:21
Joined
Nov 25, 2004
Messages
1,867
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.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:21
Joined
Feb 19, 2002
Messages
43,275
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.

 

GPGeorge

Grover Park George
Local time
Today, 00:21
Joined
Nov 25, 2004
Messages
1,867
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.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:21
Joined
Feb 19, 2002
Messages
43,275
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.
 

jpl458

Well-known member
Local time
Today, 00:21
Joined
Mar 30, 2012
Messages
1,038
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.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:21
Joined
Feb 19, 2002
Messages
43,275
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.
 

jpl458

Well-known member
Local time
Today, 00:21
Joined
Mar 30, 2012
Messages
1,038
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
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:21
Joined
Feb 19, 2002
Messages
43,275
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

  • Description of bookmarking schema_20221029.zip
    69 KB · Views: 91

jpl458

Well-known member
Local time
Today, 00:21
Joined
Mar 30, 2012
Messages
1,038
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.
 

moke123

AWF VIP
Local time
Today, 03:21
Joined
Jan 11, 2013
Messages
3,920
Posted a week ago

 

Users who are viewing this thread

Top Bottom