Word Forms and Reset Button

K

Kay

Hi all,

I need advice concerning several Word forms. First, I understand that you
can't control tab order without VB and if you use the code, you cannot click
in the fields. Are you sure there is no way around the click thing? If we
use a user form to fill in the document form fields instead, how will that
affect calculated fields we already have in our document? This form will be
published and downloaded by inexperienced users. Will the form pose any
risks with VB code run on outdated operating systems and old versions of
word? Once they fill out the doc via the userform, how can they rerun the
form without having to download again?

If we decide to stay with just the word form, no userform interface, can we
put a reset button in the document that will clear the form fields so they
can fill out another. We think we might want a print and a save as well.

Your wisdom will be appreciated and your advice taken seriously...so thanks
in advance.
 
G

Graham Mayor

You could fill a protected form from the results of a userform. Imagine a
userform with five text fields, a check box and two buttons; and a protected
form with five text form fields and a check box. Assuming the use of default
names throughout (though in practice you should use more meaningful names),
the following userform code will fill the protected form with the values
inserted in the user form. The tab order of the protected form is
irrelevant. Calculated form fields should still work (though you should
error trap the user form against non-numeric input for those fields that
contribute to the calculation). Or you could perform the calculations in the
macro and write the results to fields. There would be no need to reset the
form as the userform will update the fields. In practice the form should be
saved as a template, new documents created from it and the userform called
from an autonew macro.

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub CommandButton2_Click()
Unload Me
With ActiveDocument
.FormFields("Text1").Result = Me.TextBox1.Value
.FormFields("Text2").Result = Me.TextBox2.Value
.FormFields("Text3").Result = Me.TextBox3.Value
.FormFields("Text4").Result = Me.TextBox4.Value
.FormFields("Text5").Result = Me.TextBox5.Value
.FormFields("Check1").CheckBox.Value = Me.CheckBox1.Value
.Fields.Update
End With
End Sub

For the basics, see Word MVP FAQ - Userforms
http://word.mvps.org/FAQs/Userforms.htm

for a more in depth explanation, see
http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
K

Kay

Graham,

Thanks... great info and simple code. I will look at the sights
recommended. Can I assume that users with older systems will not have a
problem with this user form interface. Many will need to just print the form
and write in the answers. All will have to print and fax or attach to
email. Will they be able to just cancel out of the User Form? I am told
that 85% of the users will only print and write in the answers.
 
G

Graham Mayor

Users of older system should not have a problem There is very little
overhead attributable to the userform and users can cancel (or leave the
fields blank) if they wish to fill the form with a pen. The bigger issue is
persuading users to run the macros. You cannot force that. You can add code
to the userform to print and save the form - add the lines
..Printout
..Save
immediately below
..Fields.Update

You may find http://www.gmayor.com/ExtractDataFromForms.htm useful?
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top