How to insert a database field into an MS WORD document and print document from an application

I have to print a questionnaire that is in MS WORD format to send to many establishments.  The  establishment's name and address are in a database and are indexed by a unique id field.  I want to develop a procedure that will insert the unique id field then print the questionnaire for each establishment that is in my database.  

Can this be done using an MS-WORD macro?  I have developed quite a few database applications in VB6  but has never done anything involving the MS Office suite, so can someone please give me an overview of how this is achieved or point me to some resource that explains it.  Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You probably don't need a macro. You can use mail merge. There is a wizard for it via the menu (Tools/Letters and Mailings, Mail Merge...)

Come back here if you get stuck
Lee SavidgeCommented:

If you don't do mail merge which, by the way, is the  best option, then I would investigate setting up a document that contains the letter structure you want but where the variable fields like name and address are entered as Bookmarks. Then you can write a VB app that queries the database and loops through the recordset and replaces each bookmark with the correct information. You would need to refernce the MS Word application in your VB program and then create a new Word object. Ther are plenty of examples of using bookmarks for automating Word to do mail merge type functions.

Here is one example:
Here is a list of URLs:

The bookmarks is a way that I have used in the past and it works well. A tip when you Automate Word... Remember the DisplayAlerts function.


desmondgAuthor Commented:
I am not sure that mail merge is what I want since the intention is that the establishment should remain anonymous.  The questionnaire will be hand delivered.  No name nor address information should be printed on the questionnaire, only the ID field.  The delivered will know where to deliver the questionnaire because that person will have access to the database.

I am looking at the bookmark suggestion.
You can choose which fields are to be shown on the document. If you only need the ID, just insert that field.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
desmondgAuthor Commented:
Thanks GrahamSkan.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.