![]() |
|
#1
|
|||
|
|||
![]()
Hello
Please help. How to change words dependent on the selected value from the dropdown list. I am adding an attachment in which I showed and described the problem. Sorry for my English. I use Google translator Kiluk |
#2
|
||||
|
||||
![]()
Try the attached. I've given your dropdown content control a 'Master' tag and each of the output content controls I've added a 'Slave' tag.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thank you very very very much for help.
You are great |
#4
|
|||
|
|||
![]()
While it takes a bit more work, in cases involving combobox or dropdown list, you can leverage the ContentControlBeforeStoreUpdate event. It provides a pseudo change event. To make it work, you have title and map the content controls.
Code:
Private Sub Document_ContentControlBeforeStoreUpdate(ByVal ContentControl As ContentControl, Content As String) Dim oNode As CustomXMLNode Dim lngIndex As Long If ContentControl.Tag = "Master" Then Select Case Content Case 1, 2, 3 For lngIndex = 1 To 5 Set oNode = ContentControl.XMLMapping.CustomXMLPart.SelectSingleNode(Replace(ContentControl.XMLMapping.XPath, "Master", "Slave" & lngIndex)) oNode.Text = "Gender " & Content & " output " & lngIndex & " text" Next lngIndex Case Else For lngIndex = 1 To 5 Set oNode = ContentControl.XMLMapping.CustomXMLPart.SelectSingleNode(Replace(ContentControl.XMLMapping.XPath, "Master", "Slave" & lngIndex)) oNode.Text = ChrW(8203) Next lngIndex End Select End If lbl_Exit: Exit Sub End Sub Last edited by gmaxey; 12-14-2018 at 07:28 AM. |
#5
|
|||
|
|||
![]()
Thank you very much for help.
I stay at the first solution. After selecting from the drop-down list each text must have a different one, that's why I can not use your proposal. |
#6
|
|||
|
|||
![]()
Use the one you wish. I am not competing with anyone here for points. Clearly you didn't pay much attention as you changed selection because the text did change and behave exactly as it does with the first solution.
If you want to be more creative with the change you could use something like this: Code:
Private Sub Document_ContentControlBeforeStoreUpdate(ByVal ContentControl As ContentControl, Content As String) Dim oNode As CustomXMLNode Dim lngIndex As Long If ContentControl.Tag = "Master" Then Select Case Content Case 1 For lngIndex = 1 To 5 Set oNode = ContentControl.XMLMapping.CustomXMLPart.SelectSingleNode(Replace(ContentControl.XMLMapping.XPath, "Master", "Slave" & lngIndex)) Select Case lngIndex Case 1: oNode.Text = "One, two buckle my shoe" Case 2: oNode.Text = "three, four shut the door" Case 3: oNode.Text = "five, six pick up sticks" Case 4: oNode.Text = "seven, eight close the gate" Case 5: oNode.Text = "nine, ten the big fat hen." End Select Next lngIndex Case 2 For lngIndex = 1 To 5 Set oNode = ContentControl.XMLMapping.CustomXMLPart.SelectSingleNode(Replace(ContentControl.XMLMapping.XPath, "Master", "Slave" & lngIndex)) Select Case lngIndex Case 1: oNode.Text = "one little, two little" Case 2: oNode.Text = "three little, four little" Case 3: oNode.Text = "five little, six little" Case 4: oNode.Text = "seven little, eight little" Case 5: oNode.Text = "nine little, ten little (you pick) boys." End Select Next lngIndex Case 3 For lngIndex = 1 To 5 Set oNode = ContentControl.XMLMapping.CustomXMLPart.SelectSingleNode(Replace(ContentControl.XMLMapping.XPath, "Master", "Slave" & lngIndex)) Select Case lngIndex Case 1: oNode.Text = "AAAAAAAAAAA" Case 2: oNode.Text = "BBBBBBBBBBB" Case 3: oNode.Text = "CCCCCCCCCCC" Case 4: oNode.Text = "DDDDDDDDDDD" Case 5: oNode.Text = "EEEEEEEEEE" End Select Next lngIndex Case Else For lngIndex = 1 To 5 Set oNode = ContentControl.XMLMapping.CustomXMLPart.SelectSingleNode(Replace(ContentControl.XMLMapping.XPath, "Master", "Slave" & lngIndex)) oNode.Text = ChrW(8203) Next lngIndex End Select End If lbl_Exit: Exit Sub End Sub |
#7
|
|||
|
|||
![]()
Thank you very very very much for your help.
You are great |
#8
|
|||
|
|||
![]()
Why, when I copy master and slave 1 - 5 objects to a new file, nothing works.
I also copy the macro to a new file. Everything works only on your file |
#9
|
||||
|
||||
![]()
That all depends on who you're replying to...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
![]()
I would guess based on what you said you have done is that you haven't mapped the content controls to a customXMLPart.
|
#11
|
|||
|
|||
![]()
I have not mapped content control on a customXMLpart.
it's getting too complicated Can your macropod suggest working after choosing in the drop-down box, or is it necessary to leave the drop-down box - click outside this field? |
#12
|
||||
|
||||
![]()
With the code I posted it is necessary to exit the dropdown, whether by clicking elsewhere or otherwise. If you don't, how is Word to know you've decided which option you've settled on. That said, for some code to simulate a change event within a dropdown, see Greg's code here: https://gregmaxey.com/word_tip_pages...om_events.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to find (highlight) two and more words in a list of 75k single words in Word 2010 | Usora | Word | 8 | 05-29-2018 03:34 AM |
Selection of a dropdown creates another dropdown wih the list | krishnamurthy.ka2810 | Word VBA | 1 | 04-26-2018 11:44 PM |
how to shows cells range depending on dropdown menu value | mfran2002 | Excel | 5 | 10-26-2017 08:08 AM |
Dropdown list - Words with spaces | Challebjoern | Excel Programming | 0 | 05-23-2017 04:09 AM |
Changing dropdown list colors in office 2010 forms | Barry Bolton | Word | 1 | 02-19-2014 03:26 PM |