View Single Post
 
Old 11-16-2020, 12:53 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote