SQL and MS Word

  • Does anyone know if it's possible and if so, some quick hints / research links to do the following:

    I have a word document that is basically a form letter.  Inside of that form letter however is some If--Then statements to display different variable verbage based on certain criteria.

    Needless to say, it's bulky and clumsy to use and what I'm wonder is if it would be possible to simply have SQL put all of that verbage into a database field (complete with bolding various pieces,etc) and be able to create that information from within SQL such that all word (or another program) would have to do is read the field and print it.

    A quick example:

    Hi, John SmithThanks for reading my letter and we hope to hear back from you before April 15,2007.

    (Picture of a Signature)

    With John Smith / April 15, 2007 being variable pieces of information that I'd want to insert into the string.

  • I am partly posting a reply because no one else has, though I am unable to find my notes on the subject.

    I had to once design a program to take data in access, well beyond the names and dates, and insert it into a word template, resulting in a document.  I inserted bookmarks (I think) into the word document and then used code to bring the information from the recordset into the word document.  If you do a search on word automation you might find something.

    I know that's rough, but I don't have any more time to look for the notes.  Maybe I'll try again in a few days.

     

  • I did much the same, in that I'm able to insert the values in-line into the segment on the word document along with the formatting for each section via the If then ability inside of word.

    However, what I'm wanting to do now is to instead create the entire verbage inside of SQL and just pass that information directly to Word.  (Actually it's to a program called Planet Press (or something that sounds like that, I'm getting the info from a mail vendor who doesn't speak perfect english) that is much faster than word, but can't handle all of the If-then's).

  • If you want to create the verbiage in SQL using similar If..Then logic then you probably want to use the CASE function in your query. You can find further info in BOL.  This would probably get you the text that you want, however, I'm not sure about the bolding or underlining.  Your vendor would have to tell you what formatting markup codes to send in your text string to bold or underline words.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply