Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2019, 11:49 PM
jhansrod jhansrod is offline Assign selected value from DropDown to a variable Windows 10 Assign selected value from DropDown to a variable Office 2016
Novice
Assign selected value from DropDown to a variable
 
Join Date: Jun 2019
Posts: 16
jhansrod is on a distinguished road
Default Assign selected value from DropDown to a variable

Hi All

As I continue my learning, I would like to know how to assign a value from a dropdown list to a variable or alternatively how can I use "if... then ... else" to change other variables based on what a user selects.

Thank you


J
Reply With Quote
  #2  
Old 06-13-2019, 12:57 AM
macropod's Avatar
macropod macropod is offline Assign selected value from DropDown to a variable Windows 7 64bit Assign selected value from DropDown to a variable Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

See, for example:
https://www.msofficeforums.com/word-...down-list.html
https://www.msofficeforums.com/word-...recursive.html
https://www.msofficeforums.com/word-...down-list.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 06-13-2019, 11:58 AM
jhansrod jhansrod is offline Assign selected value from DropDown to a variable Windows 10 Assign selected value from DropDown to a variable Office 2016
Novice
Assign selected value from DropDown to a variable
 
Join Date: Jun 2019
Posts: 16
jhansrod is on a distinguished road
Default

Thank you and kindly excuse me if I am not being clear.

I have the code as per below which works great, however I would like to take different parts of the result and have them used in different part of the documents.

The example output of the below as follows:

Drop-Down List Content Control PROPERTIES:
Display Name = Head Office
Value = StreetAddress|Boxaddress|TelNo|Email

CODE:
If .Title = "OFFICE" Then
For i = 1 To .DropdownListEntries.Count
If .DropdownListEntries(i).Text = .Range.Text Then
StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
Exit For
End If
Next
ActiveDocument.ContentControls(2).Range.Text = StrDetails
End If

OUTPUT:
StreetAddress
BoxAddress
TelNo
Email


REQUIREMENT:
Plain Text Content Control to be assigned values as follows:
StAdr = StreetAddress
BxAdr = Boxaddress
TNo = TelNo
Eml = Email

With this, one can place and use the values anywhere needed in the document.

Thank you
J
Reply With Quote
  #4  
Old 06-13-2019, 04:46 PM
macropod's Avatar
macropod macropod is offline Assign selected value from DropDown to a variable Windows 7 64bit Assign selected value from DropDown to a variable Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

See: https://www.msofficeforums.com/word-...tml#post120392
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
variable assignment



Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing content control data from excel and populate two fields on selected dropdown badarlodhi Word VBA 8 02-08-2023 10:47 AM
Assign selected value from DropDown to a variable Conditionally Color Formatting Text selected from a dropdown list in Word 2010 pgammag Word 9 08-20-2019 04:17 PM
How to assign the clipboard value to a variable? fosterpapillon Word VBA 4 03-06-2017 07:02 PM
assign variable name to WORD text norwood Word VBA 2 09-13-2013 08:00 AM
Change cell color everytime a value is selected in dropdown list angelica_gloria Excel 4 01-27-2012 06:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:53 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