Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-19-2020, 02:01 PM
Irimi-Ai Irimi-Ai is offline Help with G Maxey's Content Control Custom Event Windows 7 32bit Help with G Maxey's Content Control Custom Event Office 2013
Novice
Help with G Maxey's Content Control Custom Event
 
Join Date: Apr 2017
Posts: 3
Irimi-Ai is on a distinguished road
Default 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"
Here's the snippet where I edited the OnChange directives:

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"
However, I think only the "Case 'Civilian'" portion is needed since nothing should happen if the user selects "Army" from the drop-down list.

Appreciate any help!
Reply With Quote
  #2  
Old 11-19-2020, 02:20 PM
gmaxey gmaxey is online now Help with G Maxey's Content Control Custom Event Windows 10 Help with G Maxey's Content Control Custom Event Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
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

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

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with G Maxey's Content Control Custom Event Content Control Dropdowns - How to duplicate the content control and allow a second choice ashleyf Word VBA 2 03-19-2020 09:11 AM
Help with G Maxey's Content Control Custom Event Create Custom Document Properties with Content Control kschmidt Word VBA 7 02-04-2019 03:09 PM
Help with G Maxey's Content Control Custom Event Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
Help with G Maxey's Content Control Custom Event How to Control Worksheet Event Handler in Module? tinfanide Excel Programming 2 10-19-2014 09:46 AM
Help with G Maxey's Content Control Custom Event Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM

Other Forums: Access Forums

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


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