Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 03-15-2024, 08:36 AM
gmaxey gmaxey is offline Toggling control checkboxes to true when a value in a control drop down is selected Windows 10 Toggling control checkboxes to true when a value in a control drop down is selected Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Your code seems to work fine here. Not to poke you in the eye with the obvious, but unfortunately the "trigger" is the act of exiting the content control. Therein lines the continuing stupidity of Microsoft (after over 15 years) of not have a content control "change" event.




Fortunately with Dropdowns, there is a "pseudo" change event called the ContentControlBeforeContentUpdate event. You can use it and XML mapping to do what you want. Attaching a demo file, but here is the code:

Code:
Private Sub Document_ContentControlBeforeContentUpdate(ByVal ContentControl As ContentControl, Content As String)
Dim oCXP As CustomXMLPart
  Select Case ContentControl.Title
    Case "ROLE"
      Set oCXP = ContentControl.XMLMapping.CustomXMLPart
      oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:RPT[1]").Text = "false"
      oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:DS[1]").Text = "false"
      oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:SPT[1]").Text = "false"
      Select Case Content
        Case "A"
         oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:RPT[1]").Text = "true"
         oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:DS[1]").Text = "true"
        Case "B"
          oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:DS[1]").Text = "true"
          oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:SPT[1]").Text = "true"
        Case "C"
          oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:RPT[1]").Text = "true"
        Case "D"
          oCXP.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:SPT[1]").Text = "true"
      End Select
    Case Else
  End Select
End Sub
Attached Files
File Type: docm Dependent checkboxes.docm (38.7 KB, 2 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Tags
checkbox, office365 desktop, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning Values to content control checkboxes and calculating results nuraish Word Tables 1 08-18-2021 03:14 AM
Using Content Control Checkboxes to open associated excel files shaztastic Word VBA 5 08-26-2018 07:13 AM
Toggling control checkboxes to true when a value in a control drop down is selected Content Control Checkboxes wlcdo2 Word VBA 3 01-05-2017 05:52 PM
Toggling control checkboxes to true when a value in a control drop down is selected Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
Toggling control checkboxes to true when a value in a control drop down is selected Assigning Values to content control checkboxes and calculating results creative cathy Word Tables 13 10-07-2012 08:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft