#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
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 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 |
#4
|
||||
|
||||
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
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 |
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 |