Solved

Checkbox controlox

Posted on 2004-09-20
1
195 Views
Last Modified: 2011-10-03
Hello, I have two checkboxes on my word document, how do i get it to when the second checkbox is clicked by the user  textbox5 will appear and allow the user to type in data. If checkbox1 is click then hide textbox5.
0
Comment
Question by:sandramac
1 Comment
 
LVL 11

Accepted Solution

by:
Steiner earned 500 total points
ID: 12109442
Unfortunately you don't have a possibility to react on a click, but you can do this when the user leaves a checkbox. I assume that checkbox1 and 2 can't be checked at the same time? The try this, insert this code into a module:

Sub LeaveCheckBox1()
   If ActiveDocument.FormFields("Checkbox1").CheckBox.Value = True Then
      ActiveDocument.FormFields("Checkbox2").CheckBox.Value = False
      ActiveDocument.Unprotect
      ActiveDocument.FormFields("Textbox5").Range.Font.Hidden = True
      ActiveDocument.Protect wdAllowOnlyFormFields, True
   End If
End Sub

Sub LeaveCheckBox2()
   If ActiveDocument.FormFields("Checkbox2").CheckBox.Value = True Then
      ActiveDocument.FormFields("Checkbox1").CheckBox.Value = False
      ActiveDocument.Unprotect
      ActiveDocument.FormFields("Textbox5").Range.Font.Hidden = False
      ActiveDocument.Protect wdAllowOnlyFormFields, True
   End If
End Sub

Please not that the document protection has no password set in this example, if you want to have a password you'll need to add that to the 2 subs, too, as they need to unprotect the document in order to set the hidden property.

You check the properties of your 2 checkboxes and add a call to LeaveCheckBox1 as exit macro for the first checkbox and do the same thing for the 2nd one.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now