Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Userform in Word with checkboxes 1

Status
Not open for further replies.

emzadi

IS-IT--Management
Feb 13, 2001
69
US
I have created a userform in VBA for my Word document. It works fine when the user needs to enter text. However, I want the user to be able to click on yes/no checkboxes as well, but can't seem to make this work.

Here is the code so far for my userform, but I don't know where/how to add the checkboxes:

Private Sub cmdCreateLetter_Click()
With ActiveDocument
.Bookmarks("Name").Range.InsertBefore txtName
.Bookmarks("Address").Range.InsertBefore txtAddress
.Bookmarks("CityStateZip").Range.InsertBefore txtCityStateZip
.Bookmarks("Salutation").Range.InsertBefore txtSalutation
.Bookmarks("Initials").Range.InsertBefore txtInitials
End With
UserForm1.Hide
End Sub


Ideas? Help?

Thanks!

Susan Susan M. Wagner
LAPELS
emzadi1@yahoo.com
susanw@lapels.com
 
You insert a check box just like you would any other control, drag and drop it from the tool box.

I'm assuming you want to include or exclude the fields from your user form. If So, something like this:


Private Sub cmdCreateLetter_Click()
With ActiveDocument
If chk1.value = true then
.Bookmarks("Name").Range.InsertBefore txtName
Else
End If
'rest of your code here
End With
UserForm1.Hide
End Sub

 
No, actually I want the checkbox to appear on the Word document... This is for a form letter with checked and unchecked requirements listed for the recepient.

Does that make sense? Susan M. Wagner
LAPELS
emzadi1@yahoo.com
susanw@lapels.com
 
I know how to add a checkbox to my userform in VB. Those checkboxes are there already. However, I don't know how to make the checkbox show up in my form in Word.

Sorry if I'm not clear on this, and thanks for your patience. Susan M. Wagner
LAPELS
emzadi1@yahoo.com
susanw@lapels.com
 
Yes, I'm confused. You can add a checkbox to a document by using the menu choices I referenced earlier. This is not while in the VBE., but in the document view.

So, you have a checkbox on your userform, and it does..What ?
 
rofl... well it does nothing right now... but i want the user to check the checkbox on the userform, and when they click submit, for the respective checkboxes on the Word form to be checked.

Just like when the user fills in the text boxes on the userform, and clicks submit, and the contents are transferred to the Word form.

I will check for your response in the morning. Thanks so much for your help!

Susan Susan M. Wagner
LAPELS
emzadi1@yahoo.com
susanw@lapels.com
 
Thanks for all the helpful emails, Databaseguy!
You saved the day!



*sits back and admires the new form*
*tosses a handful of stars your way*


:) Susan M. Wagner
LAPELS
emzadi1@yahoo.com
susanw@lapels.com
 
Insert "Form Field" check boxes on the document.

Insert the following code behind the corresponding checkbox in the user form for the On_Click event.

If Me.CheckBox1.Value = True Then
ActiveDocument.FormFields("Check1").CheckBox.Value = True
Else
ActiveDocument.FormFields("Check1").CheckBox.Value = False
End If

Or, this is a little more elegent
ActiveDocument.FormFields("Check1").CheckBox.Value = me.checkbox1.value

Hope this helps
 
Sorry about that!
I should have tended to getting it back here. Susan M. Wagner
LAPELS
emzadi1@yahoo.com
susanw@lapels.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top