Form field on exit macro

R

Ricki Miles

I would like to create a macro that will be used at the end of a template
protected with form fields. The macro needs to determine if one or more of
the check box fields are filled in. If so, the macro proceeds to do several
tasks. How can I check if one or more check boxes are filled in?

TIA,

Ricki
 
J

Jay Freedman

Hi Ricki,

Sub ExitMacro()
Dim oFld As FormField
Dim bChecked As Boolean

bChecked = False

For Each oFld In ActiveDocument.FormFields
If oFld.Type = wdFieldFormCheckBox Then
If oFld.CheckBox.Value = True Then
bChecked = True
Exit For
End If
End If
Next oFld

If bChecked = True Then
'do stuff here
MsgBox "At least one checked box"
Else
MsgBox "All boxes unchecked"
End If
End Sub
 
R

Ricki Miles

Thanks for the information,

Ricki
Jay Freedman said:
Hi Ricki,

Sub ExitMacro()
Dim oFld As FormField
Dim bChecked As Boolean

bChecked = False

For Each oFld In ActiveDocument.FormFields
If oFld.Type = wdFieldFormCheckBox Then
If oFld.CheckBox.Value = True Then
bChecked = True
Exit For
End If
End If
Next oFld

If bChecked = True Then
'do stuff here
MsgBox "At least one checked box"
Else
MsgBox "All boxes unchecked"
End If
End Sub
 
R

Ricki Miles

Hi again,

What if I only want to check if the current check box field is checked and
then take action from there?

TIA,

Ricki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top