Sandi,
If you use CheckBox type formfields you can also do something like this:
Sub SetMyFormFieldCheckboxValue()
With ActiveDocument
If .Bookmarks.Exists("myFormFieldCheckBox") Then
With .FormFields("myFormFieldCheckBox")
If .Type = wdFieldFormCheckBox Then
If myUserFormCheckBox.Value = True Then
.CheckBox.Value = True
Else
.CheckBox.Value = False
End If
End If
End With
End If
End With
End Sub
This assumes you have a CheckBox formfield in your template / document
called "myFormFieldCheckBox" and a related CheckBox control on your UserForm
called "myUserFormCheckBox".
I've just completed a template that has a heap of CheckBox formfields on it
(and, of course, an equal number of CheckBox controls in the UserForm), so I
actually created a procedure that accepts arguments to do this. It looks
something like this:
Sub SetCheckboxValue(BkmkName As String, ByVal myValue As Boolean)
With ActiveDocument
If .Bookmarks.Exists(BkmkName) Then
With .FormFields(BkmkName)
If .Type = wdFieldFormCheckBox Then .CheckBox.Value = myValue
End With
End If
End With
End Sub
I call this procedure thusly:
Private Sub InsertRequiredDocumentsDetails()
SetCheckboxValue "chkELFA", chkELFA.Value
SetCheckboxValue "chkSSA", chkSpecificSecurityAgreement.Value
End Sub
Actually, it's not *exactly* like that because I don't work with the
ActiveDocument object; I instantiate an instance of a Document object and set
it to the ActiveDocument, and then refer to this specific Document object. I
also collect the information from the various UserForm controls and then
unload the UserForm prior to putting content into the document. So in my code
there are no references to 'ActiveDocument' or to any particular UserForm
control. Instead I refer to 'myDoc' (which is the specific Document object
mentioned above) and pass the Boolean variables that are used to collect the
information from the .Value properties of the UserForm CheckBox controls...
But you get the idea. ;-D
Email me if you have questions.
--
Cheers!
Gordon
Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.