PDA

View Full Version : Solved: Word form checkbox problem



hunsnowboard
03-18-2010, 11:05 PM
Hi Everyone! I have a very annoying problem and I can't figure it out how can I get it to work. I do not know how to control checkboxes through VBA.

I mean I can control the userform checkboxes (the one which if is true shows a thick mark), but I really do not know how to use the simple form checkboxes (the one which if is true shows an X).

So the userform checkbox object I can control with the ActiveDocument.FormFields(1).Checkbox.Value = True.... but I just cannot figure how can I get the other one working? What command should I use? Please could you give me an example?
Thank you in advance!

lucas
03-19-2010, 07:40 AM
like the attached?

You must protect the document for forms only.

fumei
03-19-2010, 08:49 AM
"So the userform checkbox object I can control with the ActiveDocument.FormFields(1).Checkbox.Value = True...."

This is incorrect. A userform checkbox is NOT controled by FormFields. A userform checkbox is NOT a FormField.

A FormField is in the document, not a userform.

A userform checkbox is:

(if in the userform code module...)

checkboxNAME.checkboxPROPERTY

Examples:

CheckBox1.Value = True
CheckBox1.Caption = "This is the checkbox"
CheckBox1.Height = 100
CheckBox1.Picture = LoadPicture("c:\Imp_bullet.jpg")
etc. etc.


The main property used of FormField checkboxes is .Result.

hunsnowboard
03-20-2010, 04:15 AM
Thank you all for the answers! But my problem is still not solved. :(

I need this checkboxes to be controlled from a userform. Let's say if I fill out a textbox in the userform than this form checkbox should be true (x marked) in the word document. How could I do that?

lucas
03-20-2010, 08:12 AM
See if the attached helps.

hunsnowboard
03-20-2010, 09:25 AM
Yes! :) Thank you very much! This is what I wanted! Just 2 last questions! How can I protect the document for forms only? (Which menu and where?)
Where and how can I set the name of the checkbox? (In your case "Check1"

Thank you very much in advance!

lucas
03-20-2010, 09:45 AM
How can I protect the document for forms only? (Which menu and where?)


In 2003 its tools - protect document. you will get a dialog on the right(on my computer) check the second choice, ie editing restrictions and in the drop down select filling in forms. Then go to step 3 to start enforcing and you can add a password although you don't have to.


Where and how can I set the name of the checkbox? (In your case "Check1"


unprotect the document and right click on the checkbox.

select properties and when the dialog comes up look towards the bottom for the bookmark name. That's what I used.

hunsnowboard
03-20-2010, 02:15 PM
Thank you so much! Thank you!

Cote1980
11-09-2010, 08:33 AM
This was so helpful