PDA

View Full Version : simple VBA Questions



dtrompstine
11-04-2010, 04:56 PM
Hi,
I am very new to this, i have done some VB.Net in the past but have forgoten most of it :P

all i am trying to do is get a checkbox in a userform to activate a checkbox in the actual word document.

at the moment i am only useing bookmarks to transfer data to the document.

so if the checkbox in the userform is called chk1 and the one in the document is called chk2 what code would i put in the "submit" button in order to transfer the value of one to the other... thx

gmaxey
11-05-2010, 05:11 AM
Assume checkboxes in form are frmChk# and checkboxes in document are docChk#:

Private Sub CommandButton1_Click()
If Me.frmChk1 Then
ActiveDocument.FormFields("docChk1").CheckBox.Value = True
Else
ActiveDocument.FormFields("docChk1").CheckBox.Value = True
End If
If Me.frmChk2 Then
ActiveDocument.FormFields("docChk2").CheckBox.Value = True
Else
ActiveDocument.FormFields("docChk2").CheckBox.Value = True
End If











Hi,
I am very new to this, i have done some VB.Net in the past but have forgoten most of it :P

all i am trying to do is get a checkbox in a userform to activate a checkbox in the actual word document.

at the moment i am only useing bookmarks to transfer data to the document.

so if the checkbox in the userform is called chk1 and the one in the document is called chk2 what code would i put in the "submit" button in order to transfer the value of one to the other... thx

fumei
11-05-2010, 10:03 AM
Or, since you are making the values equivalent...

ActiveDocument.FormFields("chk2").CheckBox.Value = Me.chk1

The value of chk2 is the same as the value of chk1 - whatever it is.

If chk1 = True (checked) then chk2 = True (checked)
If chk1 = False (unchecked) then chk2 = False (unchecked)