Solved

Checkbox controlox

Posted on 2004-09-20
1
188 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

758 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

22 Experts available now in Live!

Get 1:1 Help Now