Hi,
I have to fill out long word forms regularly and I made a macro to check all checkboxes in a column in a table (see code below). It works fine except when a cell has more than one checkbox, then only the first checkbox in a cell gets checked.
The problem in my code is that when I update a checkbox, the selection is reset (which is logical) but that also automatically deletes/resets the ffs collection (which I find very weird) so the remaining checkboxes don't get checked. Anyone got a solution?
Sub checkcol()
Dim col As Column
Dim cl As Cell
Dim ffs As FormFields
Dim ff As FormField
If Selection.Information(wdWithInTable) Then
Set col = Selection.Columns(1)
For Each cl In col.Cells
cl.Select
Set ffs = Selection.FormFields
For Each ff In ffs
ff.CheckBox.Value = True
Next ff
Next cl
End If
End Sub
I have to fill out long word forms regularly and I made a macro to check all checkboxes in a column in a table (see code below). It works fine except when a cell has more than one checkbox, then only the first checkbox in a cell gets checked.
The problem in my code is that when I update a checkbox, the selection is reset (which is logical) but that also automatically deletes/resets the ffs collection (which I find very weird) so the remaining checkboxes don't get checked. Anyone got a solution?
Sub checkcol()
Dim col As Column
Dim cl As Cell
Dim ffs As FormFields
Dim ff As FormField
If Selection.Information(wdWithInTable) Then
Set col = Selection.Columns(1)
For Each cl In col.Cells
cl.Select
Set ffs = Selection.FormFields
For Each ff In ffs
ff.CheckBox.Value = True
Next ff
Next cl
End If
End Sub