Code:
Option Explicit
Private WithEvents oCXPart As CustomXMLPart
Private Sub Document_Open()
Set oCXPart = ActiveDocument.CustomXMLParts.SelectByNamespace("http://TheAnchorage.com").Item(1)
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.
If Not InUndoRedo Then 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)
If Not InUndoRedo Then ProcessChange NewNode
lbl_Exit:
Exit Sub
End Sub
Sub ProcessChange(oNodePassed As Office.CustomXMLNode, Optional bDeadNode As Boolean = False)
Dim oCC As ContentControl
Dim lngIndex As Long
Select Case oNodePassed.ParentNode.BaseName
Case "CBM"
If oNodePassed.Text = "true" Then
For lngIndex = 1 To 7
ActiveDocument.SelectContentControlsByTitle("Checkbox" & lngIndex).Item(1).Range.Font.ColorIndex = wdAuto
Next lngIndex
Else
For lngIndex = 1 To 7
ActiveDocument.SelectContentControlsByTitle("Checkbox" & lngIndex).Item(1).Range.Font.ColorIndex = wdWhite
Next lngIndex
End If
End Select
lbl_Exit:
Exit Sub
End Sub