#1
|
|||
|
|||
Help with G Maxey's Content Control Custom Event
Hi there,
I'm way out of my league, and need help. I need to use example #2 on the following Greg Maxey website, but with some tweaks: Content Control Custom Events I have a drop-down list box content control box labeled "Service" that is the master. It has 5 drop-down options. I have 4 rich text content control boxes that need to be slaved, and all are already labeled differently. If the user selects option 1-4 in the drop-down, nothing should happen to the 4 slave text content control boxes. However, if the user selects option 5 in the drop-down, then all 4 slave rich text content control boxes should have the text "N/A" appear. I've poked around the Demonstration Package from the website above (e.g., adding to the array of linked relationships, etc.), but got stuck with no defined oCC_Linked_2 error. Here's the snippet of the modMain module I edited to get the additional slave rich text content fields: Code:
Dim arrLinked(7, 4) As String Dim i As Long Dim oDoc As Document On Error GoTo Err_Handler 'Build array of link relationships arrLinked(0, 0) = "Name1" arrLinked(0, 1) = "Name2" arrLinked(1, 0) = "Service" arrLinked(1, 1) = "Rank" arrLinked(1, 2) = "MOS" arrLinked(1, 3) = "Unit" arrLinked(1, 4) = "Commander" Code:
Case "Service" Select Case oCC_InEvent.Range.Text Case "Army" oCC_Linked_1.Range.Text = "" oCC_Linked_2.Range.Text = "" oCC_Linked_3.Range.Text = "" oCC_Linked_4.Range.Text = "" Case "Civilian" oCC_Linked_1.Range.Text = "N/A" oCC_Linked_2.Range.Text = "N/A" oCC_Linked_3.Range.Text = "N/A" oCC_Linked_4.Range.Text = "N/A" Appreciate any help! |
#2
|
|||
|
|||
There is a lot of good stuff in that page but it has been a long time since I've looked at it. In many instances, the built-in events can be used as pseudo change events. In your case, I would add a customXMLPart
<?xml version="1.0"?> <CC_Map_Root xmlns="http://TheAnchorage.com"> <Service></Service> <oCC_Linked_1></oCC_Linked_1> <oCC_Linked_2></oCC_Linked_2> <oCC_Linked_3></oCC_Linked_3> <oCC_Linked_4></oCC_Linked_4> </CC_Map_Root> Map your CCs to the respective node then use: Code:
Private Sub Document_ContentControlBeforeContentUpdate(ByVal ContentControl As ContentControl, Content As String) Select Case ContentControl.Title Case "Service" With ContentControl If .XMLMapping.CustomXMLNode.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:Service").Text = "Civilian" Then 'E.g., if the selected entry = "Civilian" and the fifth LE = "Civilian" then .XMLMapping.CustomXMLNode.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:oCC_Linked_1[1]").Text = "N/A" .XMLMapping.CustomXMLNode.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:oCC_Linked_2[1]").Text = "N/A" .XMLMapping.CustomXMLNode.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:oCC_Linked_3[1]").Text = "N/A" .XMLMapping.CustomXMLNode.SelectSingleNode("/ns0:CC_Map_Root[1]/ns0:oCC_Linked_4[1]").Text = "N/A" End If End With End Select lbl_Exit: Exit Sub End Sub In the ThisDocument module |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Content Control Dropdowns - How to duplicate the content control and allow a second choice | ashleyf | Word VBA | 2 | 03-19-2020 09:11 AM |
Create Custom Document Properties with Content Control | kschmidt | Word VBA | 7 | 02-04-2019 03:09 PM |
Clicking the selected Content Control checkbox returns wrong control in vba event | DougsGraphics | Word VBA | 2 | 06-24-2015 07:31 AM |
How to Control Worksheet Event Handler in Module? | tinfanide | Excel Programming | 2 | 10-19-2014 09:46 AM |
Deleting a table from a content control -- preserving the content control | BrainSlugs83 | Word Tables | 8 | 11-14-2013 03:06 AM |