S
sg
I have a form that uses checkboxes for the user to determine which sections
should stay and which sections should go. When they are finished filling in
the form, a button runs the following macro:
Sub DeleteSection()
'
Dim oFF As FormField
On Error Resume Next
ActiveDocument.Unprotect
On Error GoTo 0
Set oFF = Selection.Sections(1).Range.FormFields(1)
If oFF.Checkbox.Value = False Then
Selection.Sections(1).Range.Delete
Else
Selection.Sections(1).Range.FormFields(1).Delete
End If
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
End Sub
It works great except that it only works for one section at a time instead
of repeating through the whole document. I have read other posts that talk
about looping but it seems everyone else is looking to use their macro for
formatting instead of deleting. Can I loop my macro?
Thanks in advance for any help.
should stay and which sections should go. When they are finished filling in
the form, a button runs the following macro:
Sub DeleteSection()
'
Dim oFF As FormField
On Error Resume Next
ActiveDocument.Unprotect
On Error GoTo 0
Set oFF = Selection.Sections(1).Range.FormFields(1)
If oFF.Checkbox.Value = False Then
Selection.Sections(1).Range.Delete
Else
Selection.Sections(1).Range.FormFields(1).Delete
End If
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True
End Sub
It works great except that it only works for one section at a time instead
of repeating through the whole document. I have read other posts that talk
about looping but it seems everyone else is looking to use their macro for
formatting instead of deleting. Can I loop my macro?
Thanks in advance for any help.