View Single Post
 
Old 04-26-2020, 01:16 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

Graham,


Things are slow. So just providing this as another example of the CC BeforeStoreUpdate Event. It takes a bit of work to setup but eliminates the need to exit the CC after making the selection.

Create three Paragraph1 CCs with the same text. Tag 1 "Paragraph1", Tag 2 "Paragraph1_Norm" and Tag 3 "Paragraph1_ST" Then set the font in "Paragraph1_ST" as strikethrouh.


Now map the Topic_1 and three associated Paragraph1 CCs to a CXMLPart (see image).


After that you can delete the "Paragraph1_Norm" and "Paragraph1_ST" CCs from the document.

Here is the needed code:
Code:
Private Sub Document_ContentControlBeforeStoreUpdate(ByVal CC As ContentControl, Content As String)
Dim oNode As CustomXMLNode, oNodeC As CustomXMLNode
  Select Case CC.Title
    Case Is = "Topic 1"
      Set oNode = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Paragraph1[1]")
      If Content = "Does Not Apply" Then
        Set oNodeC = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Paragraph1_ST[1]")
      Else
        Set oNodeC = CC.XMLMapping.CustomXMLPart.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Paragraph1_Norm[1]")
      End If
      oNode.Text = oNodeC.Text
    End Select
lbl_Exit:
  Exit Sub
 End Sub

BREAK


Paul, downloaded the document from your link and nothing happens when I change the FF DDL. I may be missing something.
Attached Images
File Type: jpg CXMLPart.jpg (29.8 KB, 30 views)
Attached Files
File Type: docm Form example.docm (73.1 KB, 5 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote