Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2018, 04:19 AM
Kiluk Kiluk is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2013
Novice
Changing words depending on the dropdown list
 
Join Date: Dec 2018
Posts: 7
Kiluk is on a distinguished road
Default Changing words depending on the dropdown list

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
Attached Files
File Type: docm change text.docm (46.4 KB, 18 views)
Reply With Quote
  #2  
Old 12-12-2018, 03:45 PM
macropod's Avatar
macropod macropod is offline Changing words depending on the dropdown list Windows 7 64bit Changing words depending on the dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,381
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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.
Attached Files
File Type: docm change text.docm (46.2 KB, 41 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-13-2018, 01:50 AM
Kiluk Kiluk is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2013
Novice
Changing words depending on the dropdown list
 
Join Date: Dec 2018
Posts: 7
Kiluk is on a distinguished road
Default

Thank you very very very much for help.
You are great
Reply With Quote
  #4  
Old 12-13-2018, 03:03 PM
gmaxey gmaxey is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
Attached Files
File Type: docm change text.docm (58.4 KB, 26 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/

Last edited by gmaxey; 12-14-2018 at 07:28 AM.
Reply With Quote
  #5  
Old 12-14-2018, 02:20 AM
Kiluk Kiluk is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2013
Novice
Changing words depending on the dropdown list
 
Join Date: Dec 2018
Posts: 7
Kiluk is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 12-14-2018, 06:50 AM
gmaxey gmaxey is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
Attached Files
File Type: docm change text.docm (58.9 KB, 24 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 12-16-2018, 05:54 AM
Kiluk Kiluk is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2013
Novice
Changing words depending on the dropdown list
 
Join Date: Dec 2018
Posts: 7
Kiluk is on a distinguished road
Default

Thank you very very very much for your help.
You are great
Reply With Quote
  #8  
Old 01-28-2019, 05:29 AM
Kiluk Kiluk is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2013
Novice
Changing words depending on the dropdown list
 
Join Date: Dec 2018
Posts: 7
Kiluk is on a distinguished road
Default

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
Reply With Quote
  #9  
Old 01-28-2019, 12:39 PM
macropod's Avatar
macropod macropod is offline Changing words depending on the dropdown list Windows 7 64bit Changing words depending on the dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,381
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Kiluk View Post
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
That all depends on who you're replying to...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 01-28-2019, 05:48 AM
gmaxey gmaxey is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I would guess based on what you said you have done is that you haven't mapped the content controls to a customXMLPart.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #11  
Old 01-28-2019, 12:53 PM
Kiluk Kiluk is offline Changing words depending on the dropdown list Windows 10 Changing words depending on the dropdown list Office 2013
Novice
Changing words depending on the dropdown list
 
Join Date: Dec 2018
Posts: 7
Kiluk is on a distinguished road
Default

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?
Reply With Quote
  #12  
Old 01-28-2019, 01:31 PM
macropod's Avatar
macropod macropod is offline Changing words depending on the dropdown list Windows 7 64bit Changing words depending on the dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,381
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:35 AM.


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