Form question

J

jb914

i have a form that includes multiple sections. sections can have checkboxes
and/or dropdown fields.

i want to allow the user to go thru the sections and check boxes pick from
drop downs.

once they are done i want them to have a toolbar button that will "hide" any
unchecked boxes and any unselected drop down boxes.

I don't want to delete the unchecked/unselected boxes since the user will
reuse the document in the future. I just need the unchecked boxes and any
unselected drop down boxes to be hidden, so, the document can be
view/printed/faxed, ect without all the clutter of the unneccesary text.

any advice would be appreciated.

thanks
JB914
 
G

Greg Maxey

This assumes that the first item of each dropdown field is one or more
spaces to produce a blank field:
Sub Test()
Dim oFF As FormField
Dim oFFs As FormFields
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
Set oFFs = ActiveDocument.FormFields
For Each oFF In oFFs
Select Case oFF.Type
Case wdFieldFormCheckBox
If oFF.Result = False Then
oFF.Range.Font.Hidden = True
End If
Case wdFieldFormDropDown
If oFF.DropDown.Value = 1 Then
oFF.Range.Font.Hidden = True
End If
End Select
Next
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
Sub Reset()
Dim oFF As FormField
Dim oFFs As FormFields
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
Set oFFs = ActiveDocument.FormFields
For Each oFF In oFFs
oFF.Range.Font.Hidden = False
Next
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
 
J

jb914

Thanks Greg!! That helps.

Greg Maxey said:
This assumes that the first item of each dropdown field is one or more
spaces to produce a blank field:
Sub Test()
Dim oFF As FormField
Dim oFFs As FormFields
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
Set oFFs = ActiveDocument.FormFields
For Each oFF In oFFs
Select Case oFF.Type
Case wdFieldFormCheckBox
If oFF.Result = False Then
oFF.Range.Font.Hidden = True
End If
Case wdFieldFormDropDown
If oFF.DropDown.Value = 1 Then
oFF.Range.Font.Hidden = True
End If
End Select
Next
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
Sub Reset()
Dim oFF As FormField
Dim oFFs As FormFields
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
Set oFFs = ActiveDocument.FormFields
For Each oFF In oFFs
oFF.Range.Font.Hidden = False
Next
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
 

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