Automate form fields in Word 2003?

S

srpd

If the end user selects the checkbox called “revision ofâ€, I want a textbox
to appear so the user can enter the previous title. I created a macro which
is simply a Text Form Field from the Forms toolbar, saved it in my document
and selected it under Exit in the Check Box Form Field Options box. When I
test it, it does not appear. After I click the check box and hit tab, I get
“Runtime Error 4605. This command is not availableâ€. What am I doing wrong?

And, how to I save the data to an excel spreadsheet for reporting purposes?
 
G

Greg

Question 1:

I suppose you could do it with hidden text. In this example the
checkbox is "Checkbox1" the formfield is "Text1"

Sub OnExit()
Dim oRng As Range
Dim oFlds As FormFields
ActiveDocument.Unprotect
Set oFlds = ActiveDocument.FormFields
Set oRng = oFlds("Text1").Range.Fields(1).Result
If oFlds("Check1").CheckBox.Value = True Then
oRng.Font.Hidden = False
Else
oRng.Font.Hidden = True
End If
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True
End Sub
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?c3JwZA==?=,
If the end user selects the checkbox called “revision ofâ€, I want a textbox
to appear so the user can enter the previous title. I created a macro which
is simply a Text Form Field from the Forms toolbar, saved it in my document
and selected it under Exit in the Check Box Form Field Options box. When I
test it, it does not appear. After I click the check box and hit tab, I get
“Runtime Error 4605. This command is not availableâ€. What am I doing wrong?
In order to insert anything into a protected document you first need to Unprotect.
Then you can insert. Finally, you need to set the protection again, but without
losing the information already entered in the form. You'll find the necessary code
to unprotect/reprotect in the Forms section of my website :)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail :)
 

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