Loop through CheckBoxes changing tag

212 Views Asked by At

I'm trying to change the Tag of a bunch of CheckBoxes (Content Control), so the tags match the CheckBox row position on a table.

Ex.: If CheckBoxes are positioned on row 4, i want all of them to have the same tag (like Row4,or something like that).

Is this possible or the Tag property is only for reading purpose?

I'll be gratefull on any advise. Thanks in advance!

Image of the table bellow

enter image description here

1

There are 1 best solutions below

0
Tim Williams On BEST ANSWER

A basic example:

Sub Tester()
    Dim cc As ContentControl, i As Long, tbl As Table, rw As Row
    
    Set tbl = ThisDocument.Tables(1)
    For Each rw In tbl.Rows
        i = i + 1
        For Each cc In rw.Range.ContentControls
            If cc.Type = wdContentControlCheckBox Then
                Debug.Print cc.Tag
                cc.Tag = "Row_" & i
            End If
        Next cc
    Next rw
End Sub