Google Answers Logo
View Question
 
Q: Generating Boilerplate in Microsoft Word based on Form entries ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: Generating Boilerplate in Microsoft Word based on Form entries
Category: Computers > Programming
Asked by: dwc-ga
List Price: $15.00
Posted: 08 Apr 2003 11:48 PDT
Expires: 08 May 2003 11:48 PDT
Question ID: 187775
Question for Microsoft Word Mavens.  I want to create a Microsoft Word
Template or Form that generates a text file based on choices.  E.g.,
allow the user to check off boxes, fill in text fields and use
pulldown menus to select choices.  Based on those choices I would like
text to be generated.

I have prepared a dummy example to show you what the FORM might look
like, and what the OUTPUT might look like.

Anything in square braces is what the user choses from.
Anything not in braces is what is seen in the FORM and in the OUTPUT
generated based on the form info.

The output MUST be in the form of a text file (and not just a print
out).

Example:

{start FORM}

Name [Text field for free text]

Favorite fruit: [drop down menu choices include Apple, Banana, Orange;
default is None]

History of food allergies [Checkboxes for Yes, No, Not sure, No reply;
the latter is the default]
	If food allergies is Yes, describe reaction [Text field for free
text]
Family history of obesity [Checkboxes for Yes, No, Not sure, No reply;
the latter is the default]

Past medical history:
	1.  Hypertension  [DropDown menu for Yes, No, Not sure, No reply; the
latter is the default]
	2.  Heart attack  [DropDown menu for Yes, No, Not sure, No reply; the
latter is the default]
	3.  Stroke  [DropDown menu for Yes, No, Not sure, No reply; the
latter is the default]
	4.  Tuberculosis  [DropDown menu for Yes, No, Not sure, No reply; the
latter is the default]
	5.  Poor Healing  [DropDown menu for Yes, No, Not sure, No reply; the
latter is the default]
	6.  Hepatitis  [DropDown menu for Yes, No, Not sure, No reply; the
latter is the default]
	7.  Hypothyroidism  [DropDown menu for Yes, No, Not sure, No reply;
the latter is the default]
Further details for past medical history [Text field for free text]	

Set Choices 1-7 to "No" [Button that, when clicked, sets menu item in
previous choices 1-7 to "No"]

Recommendation:  [Checkboxes for "Consultation with Dietitian",
"Consultation with Internist" and "No further intervention Needed"]

{end of form}

OUTPUT:

{start OUTPUT}

This is a patient history prepared for John Doe.

John Doe's favorite fruit is apples.

History of food allergies: Yes
	Type of food allergy reaction: "Face swelled up when I ate shellfish"
History of obesity: No reply

Past Medical History:
	Patient has a history of heart attack and tuberculosis.
	Patient has no history of hypertension.
	Patient not sure whether there is a history of stroke
	Patient did not reply when asked regarding a history of poor healing,
hepatitis or hypothyroidism

Based on the selections, I recommend that we arrange a consultation
with the dietitian and the internist.

{end of OUTPUT}

As you can see, there are some "if then" decision points,
concatenation of text depending on choices, etc.  I am capable of some
simple programming if I am shown or given examples that work and that
are alterable.

Payment:

No payment for simply pointing to a Microsoft help file or a book,
although comments along these lines are welcome and a tip will be
considered if help is non-trivial
$15 for pointing to a downloadable implementation of a form that can
be altered; form must implement all of the types of programming I need
$20-25 for explaining and demonstrating with VB or Word programming
how do do these things
$30-50 for a file comprising a working and alterable Microsoft Word
form that can be adapted and changed and which explains how to do so.

Please write if you have questions.

Thanks, researchers, and good luck.

Request for Question Clarification by hammer-ga on 08 Apr 2003 11:53 PDT
By asking for a text file as output, do you mean a plain ASCII text file?

- Hammer

Request for Question Clarification by hammer-ga on 08 Apr 2003 11:53 PDT
Also, what version of WOrd?

- Hammer

Clarification of Question by dwc-ga on 08 Apr 2003 13:44 PDT
Word version is 2002 (10.4219.4219 SP-2).

Clarification of Question by dwc-ga on 08 Apr 2003 13:44 PDT
Yes, ASCII Text File.

Request for Question Clarification by hammer-ga on 09 Apr 2003 12:21 PDT
Do you want Word form fields, Active X controls, or whichever is best?

- Hammer

Clarification of Question by dwc-ga on 10 Apr 2003 13:38 PDT
As long as the functionality is native to Word (e.g., no third party
Active X controls), and as long as the functionality can be modified,
e.g, through the VB editor, either is fine.  Thank you for asking.
Answer  
Subject: Re: Generating Boilerplate in Microsoft Word based on Form entries
Answered By: hammer-ga on 11 Apr 2003 07:44 PDT
Rated:5 out of 5 stars
 
OK, I think I've more than earned your $50.00! 

There is a Word 2002 document ready for you to download at:
http://www.hammerdata.com/Google/SurveyForm.doc

It is a blank Word document which contains a UserForm. The UserForm is
set to appear as soon as the document is opened. You get a UserForm by
going to the Document's code module and selecting Insert->UserForm.

For the sake of maximum visibility, I built the entire form in
runtime. Look at the code behind the UserForm. This is so you could
see what everything is and how the properties get set without it all
being hidden in dialog boxes. The exception is the command buttons.
While they get all their properties set in the code, they were
actually dropped on the UserForm in design-time. This is so they could
get event programming attached to them. You *can* attach event
programming to controls created in runtime, but I felt it would
obfuscate the techniques you are trying to learn. When you start
working with this (or other UserForms) yourself, you may want to use
design-time controls so you get the benefits of events and
autocomplete.

I concentrated on providing you with examples of a wide variety of
techniques. For example, I used option buttons instead of checkboxes
for those questions where only one of the choices could be selected. I
also demonstrated the use of subroutines and functions, operating on
design-time and run-time controls, simple file output, string
concatenation, etc. If you put your cursor on any of the methods or
properties in the code and press F1, you should get Help for that
item.

Please ask for clarification if you need any particular technique
explained.

Best regards,

- Hammer

Request for Answer Clarification by dwc-ga on 11 Apr 2003 12:56 PDT
Thank you, Hammer, that was very quick!  I have downloaded the file
and will spend some time puzzling over it.  Hopefully my head will
grok what you've done very quickly...now processing...

dwc

Clarification of Answer by hammer-ga on 11 Apr 2003 13:06 PDT
OK. Since you've got the file, I'm going to remove it from my download
area. Again, let me know if you need anything in particular explained.

- Hammer

Clarification of Answer by hammer-ga on 15 Apr 2003 05:39 PDT
DWC,

I hope that the file I provided is working out for you. 

I notice that you often do not rate questions once you have received
the answer. You may not be aware that the only way for me to receive
the additional fee you offered for the level of work performed is for
you to rate this answer and enter the additional amount as a tip.

Please let me know if you need additional clarification on this
answer.

- Hammer

Request for Answer Clarification by dwc-ga on 16 Apr 2003 04:19 PDT
Dear Hammer,

You are correct, I am not adept on Google-ology.  I am also not much
of a programmer, which is why I asked the question and it is taking me
time to puzzle through your form.  For this result to rate a full
rating I need the product to be alterable by me and unfortunately I am
a weak programmer.  You have done an excellent job of commenting out
lines which is most useful for someone who knew VB at or just below
your level.  I am WAY below your level.

1.  Is there anyway to save the document with the UserForm already
assembled so that I can more easily add and subtract buttons,
formfields, etc.?  I think it is assembled afresh each time at
initialization.

We are about to go away for a couple of days with the kids on school
vacation; if my wife saw I was at the computer she would scalp me.  So
a delay of reply to this question of a couple of days is just fine.

Thanks.

DWC

Clarification of Answer by hammer-ga on 16 Apr 2003 04:35 PDT
I'll redo the form so it is built in design-time rather than runtime.
Some of the information will be hidden in Property Sheets, but I'll
leave the original code so you can see what properties should be set.

- Hammer

Clarification of Answer by hammer-ga on 18 Apr 2003 13:47 PDT
DWC,

I built another version of the document which can be downloaded at 
http://www.hammerdata.com/Google/SurveyFormPrebuilt.doc

This one has the entire form built in design-time. Only the properties
that cannot be set on the property sheet are set in the code. Also, I
fixed a bug in the previous code where your path was not being used
properly. You can still refer to the earlier fully coded document to
see what properties were set in the property sheets.

In both versions, only the most straightforward coding techniques are
used. For the sake of clarity, I didn't use any kind of fancy tricks
or anything that is outside the reach of a beginner.

Good luck with your Word project!

- Hammer

Clarification of Answer by hammer-ga on 19 Apr 2003 06:09 PDT
DWC,

I'm glad the examples are helpful to you. You can certainly direct a
question to me, if you wish. If I am not able to answer it, I'm
certain that one of the other  Researchers will be able to help you.

- Hammer
dwc-ga rated this answer:5 out of 5 stars and gave an additional tip of: $40.00
Hammer, thanks very much.  An exceptional answer.  I appreciate your
professionalism and patience.  I also appreciate that the code is
commented out beautifully and the layout design is clean.  I will
probably need to tweak the form down the line -- can I direct a
question to you if I need further help?  Thanks again.

-- DWC

Comments  
Subject: Re: Generating Boilerplate in Microsoft Word based on Form entries
From: richard-ga on 08 Apr 2003 17:32 PDT
 
Not to say it can't be done with macros in the Word program alone, but
HotDocs is a very popular add-on to Word that does exactly what you
want if you're willing to pay for it:
http://www.hallogram.com/hotdocs/

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy