PDA

View Full Version : Writing to a Word template



mitchert
05-18-2009, 03:09 PM
This should be a simple problem, but I haven't been able to find the answer. Here's what I want to do:

Start with a Word doc that contains two paragraphs of text. The user inputs information via checkboxes and text fields. Based on the selections, the program writes different text into the template file.

Example: Template says, "Hello Goodbye." The VB program has a text field called "name" and two check boxes "yes" and "no" for the question, "do you like Microsoft?" User enters the name Chuck and checks "yes" then hits "submit." A new Word doc is created that says "Hello Chuck. I'm glad you like Microsoft. Goodbye."

That's it. (Told you it was simple.) I would much appreciate it if someone can direct me to sample code that does that sort of thing.

Tinbendr
05-19-2009, 08:33 AM
...Told you it was simple.But too vague. Akin to getting four wheels and asking how to build a car.

You've got the process backwards, too.

You start with a TEMPLATE, then create your final DOCUMENT.

Ok, let me ask a few questions.

How much data will be entered?

Who will be using it? Only you?

Will the 'couple of paragraphs of text' be copied to the new document? Or is the new text generated based on the checkboxes and textboxes. (This is the jest I'm getting.)

Does the text in the document change much/any?

I do something similar, but I use a table for data, which also holds the code, that runs userforms, that populates the final document.

Tinbendr
05-19-2009, 08:34 AM
Rats, it posted twice.

mitchert
05-19-2009, 09:39 AM
Nevermind. I'm just going to do it as a web based app using Javascript and CGI/perl since I know how to use those better than VB.

fumei
05-19-2009, 10:03 AM
It could be done fairly easily with Word (with more appropriate details), but if your users are going to be actioning this via a browser, then yes, a browser based app would be better.

It is always better to use the appropriate application.