vendredi 4 novembre 2016

Counting the number of checkboxes in ms word table

Following code is for counting the number of checked checkboxes in a formfield. How can I modifyit to count the same object in a normal table, and not a formfield?

Private Sub CommandButton2_Click()
Dim i As Long, j As Long, k As Long
k = 0
With ActiveDocument
    With .Tables(1)
        j = 3
        For i = 1 To .Rows.Count
            If .Cell(i, j).Range.FormFields(1).CheckBox.Value = True Then
                k = k + 1
            End If
        Next i
        i = .Rows.Count
    End With
End With
    MsgBox k & " instances were found"
End Sub




Aucun commentaire:

Enregistrer un commentaire