A little more difficult but eliminates the need to exit the checkbox. First retitle/tag the CCs Check_1 and Check_2 then map to a CustomXMLPart.
Code:
Option Explicit
Dim WithEvents oCXPart As CustomXMLPart
Sub AutoOpen()
Dim aCC As ContentControl
For Each aCC In ActiveDocument.ContentControls
If aCC.Type = wdContentControlCheckBox Then
aCC.Range.Paragraphs(1).CollapsedState = aCC.Checked
End If
Next aCC
On Error Resume Next
Set oCXPart = ActiveDocument.CustomXMLParts.SelectByNamespace("http://TheAnchorage.com/XMLPart").Item(1)
lbl_Exit:
Exit Sub
End Sub
Private Sub oCXPart_NodeAfterDelete(ByVal OldNode As Office.CustomXMLNode, ByVal OldParentNode As Office.CustomXMLNode, ByVal OldNextSibling As Office.CustomXMLNode, ByVal InUndoRedo As Boolean)
'This event fires when a #text node containing a value is replaced with Null value. Not applicable with checkboxes
If OldParentNode.BaseName = "Number_of_children" Then ProcessChange OldNode, True
lbl_Exit:
Exit Sub
End Sub
Private Sub oCXPart_NodeAfterInsert(ByVal NewNode As Office.CustomXMLNode, ByVal InUndoRedo As Boolean)
'This event fires when the Null value in a CXPart element node is replaced with a #text node containing a value. Not applicable with checkboxes.
ProcessChange NewNode
lbl_Exit:
Exit Sub
End Sub
Private Sub oCXPart_NodeAfterReplace(ByVal OldNode As Office.CustomXMLNode, ByVal NewNode As Office.CustomXMLNode, ByVal InUndoRedo As Boolean)
'This event fires when the initial Null value in the node is replaced with a value.
ProcessChange NewNode
lbl_Exit:
Exit Sub
End Sub
Sub ProcessChange(oNodePassed As Office.CustomXMLNode, Optional bDeadNode As Boolean = False)
Dim oNode As CustomXMLNode
Dim oCC As ContentControl
If bDeadNode Then
'Not applicable for this case
Else
Set oCC = ActiveDocument.SelectContentControlsByTag(oNodePassed.ParentNode.BaseName).Item(1)
oCC.Range.Paragraphs(1).CollapsedState = oCC.Checked
End If
lbl_Exit:
Exit Sub
End Sub