General discussion

Locked

SQL and MS Word

By geeit ·
I have a client that wants to be able to create word documents and pull contact information (name/addresses/contact info) from a sql database.

It's for thier admin staff and for multiple documents.

Can anyone advise of the enst way to do this or let me know any utilities that can be used. Thanks.

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by HAL 9000 Moderator In reply to SQL and MS Word

Well what it is you want is called Mail Merge and while it was a very common thing a while ago when Word Perfect was the WP of choice this is no longer taught or covered in teaching students how to use MS products as it is now considered as an "Advanced Procedure."

Just go to the help in Office and look up Mail Merge I'm not exactly sure how it works with MS Office as I still use Word Perfect Office as it's just so much better but there should be directions in the Help file for this.

Col

Collapse -

by HAL 9000 Moderator In reply to

That still uses the Mail Merge Feature but not in the bulk manner that I previously described.

For what you want you'll have to write some VB script to call the company/personal data when the Company or persons name is entered into the first field of the template then the unit can auto fill the rest of the required or available fields.

Try these MS knolledge Base articles you may have to modify a bit but the basics should be in there.

http://support.microsoft.com/default.aspx?scid=kb;en-us;285176

http://support.microsoft.com/default.aspx?scid=kb;en-us;285332

http://support.microsoft.com/default.aspx?scid=kb;en-us;172525

http://support.microsoft.com/default.aspx?scid=kb;en-us;829121

Collapse -

by geeit In reply to SQL and MS Word

I should have clarified a little further. What the firm wants is a front end that can be used by the staff to pull contact details for individual client letters that then takes these details and inserts then into a word document. Eg. open word, searc the firms contact database (sql) for the correct client and then bring the contact details (name, address etc) into the word document (template)

Collapse -

SQL and Word

by GWass In reply to

What type of database are you using? if you create a SQL query in your database then either publish this as a report or in most DBMS you can publish it in word.

Collapse -

Lots of ways

by Tony Hopkinson In reply to

One I've used in the past. It to have them set up a template document and set named bookmarkes where the text from the database is to go.

Run the query to get the data, load the template up in an OLE container and then do a replace of the book marked text with the relevant fields out of the query then do a save as of the filled word document

Collapse -

by Mustang Sally In reply to SQL and MS Word

MS Access is really the best tool to do automated form generation in this manner. You have your links to all the back end SQL tables in one place to minimize maintenance of data sources, can create multiple queries with various filters/parameter sources (e.g. "pick a customer" + "pick a form" + "pick various options for form" (e.g. hide sections/fields, etc.)) depending on different needs and then create and use Access reports as your templates. You can then automate the export of those reports to .rtf format (Word) and autolaunch of Word itself if you want the user to be able to further modify the resulting document after the data is pulled via macro or vb code.

Access also has a very easy to use label/mailing envelope wizard that you can also automate via macro/code.

Collapse -

by Spanr In reply to SQL and MS Word

There are probably many ways of accomplishing such a task. However, one that could work for you would be to use some VBA behind the doc.

You would need to create a form which would provide a list of clients drawn from the database. The forms available via the VBA/macro environment behind word are not as powerful as Access forms but you can create form with a combo control and populate it with data from a recordset.

The form and database query would be activated using a custom toolbar button after the template doc is opened.

Then all you need is an On-Click event which creates another recordset based on the selected client and inserts the contents of the recordset (ie address details) into the doc. Finally the user would simply finish with a "save as".

This describes the broad methodology I have used to populate an excel spreadsheet (data and graphs) - I'm sure the principles can be applied to word.

Hope this helps.

Collapse -

...I would Go with the MS Access...

by anphilot In reply to

I would best go with the MS Access project front-end, and have the SQL-backend for data input. You can then use the access to produce reports in RTF format for you letters, or if you want to get the text better formatted, then make use of mail-merge. With the mail-merge, you will format your letter, then use the wizard from Tools > Letters & Mailings > Mail Merge. All you will need is to specify you table and columns for source data, then specify where on your letter this informaion is placed. The wizaard is quite straight forward.... depending also on the version of MS Office you are using.

Back to Desktop Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums