View Single Post
 
Old 11-11-2020, 02:45 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

This seems a convoluted process but yes it is certainly possible. See attached document and image.

You will need to create the three different conditions
0) a rich text cc (Titled Result) with both check boxes and text showing
1) a richtext CC (Titled Result1) with Checkbox1 and text only
2) a rich text CC (Titled Result2) with Checkbox 2 and text only and an overall result richtext CC (titled Result) showing both checkboxes and text.

These will have to be mapped to a customXMLpart. Once done, you can remove the Result0, Result1 and Result2 richtext CCs and content.


You will need the following code in the ThisDocument class object:


Code:
Private Sub Document_ContentControlBeforeStoreUpdate(ByVal CC As ContentControl, Content As String)
  Select Case CC.Title
    Case "Checkbox1"
      'Reset so Result CC shows both checkboxes and paragraphs (Result0 node value)
      CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result[1]").Text = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result0[1]").Text
      If CC.Checked Then
        'Remap Result CC to show only checkbox 1 and text (Result1 node value)
        CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result[1]").Text = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result1[1]").Text
      End If
    Case "Checkbox2"
      'Reset so Result CC shows both checkboxes and paragraphs (Result0 node value)
      CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result[1]").Text = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result0[1]").Text
      'Remap Result CC to show only checkbox 2 and text (Result2 node value)
      If CC.Checked Then
        CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result[1]").Text = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Result2[1]").Text
      End If
  End Select
End Sub
Attached Images
File Type: jpg CustomXMLPart.jpg (19.1 KB, 29 views)
Attached Files
File Type: docm Toggle node text.docm (140.9 KB, 13 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/

Last edited by Charles Kenyon; 11-13-2020 at 11:55 AM. Reason: make list more readable
Reply With Quote