Word: DropDown entry change the entry of another DropDown

glockster

Board Regular
Joined
Mar 24, 2002
Messages
181
I'm trying this code in a macro:

Sub email()
If DropDown2.Value = "Mike Smith" Then
DropDown3.Value = "1111"
DropDown4.Value = "Mike"
End If
End Sub

I want the selection of DropDown2 to change the contents of DropDowns 3 and 4.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Go into the properties of DropDown2. Find the "Run macro on" section and select this macro from the dropdown under the "Exit" field.

When you tab (or click) out of DropDown2, the assigned macro should then run.
 
Upvote 0
Thanks!
It's giving me an error msg, I think my code is wrong but don't know enough about Word to make it right.
Any ideas on what's wrong or any good forums like this one specific to Word?
 
Upvote 0
Ah, ok. I was able to get it to work in my sample document.

Word uses different properties than Excel. So for example, the value of the dropdown controls is returned by Result, not Value. Go figure. This worked for me:

Code:
Sub email2()
If ActiveDocument.FormFields("Dropdown2").Result = "Mike Smith" Then
    ActiveDocument.FormFields("Dropdown3").Result = "1111"
    ActiveDocument.FormFields("Dropdown4").Result = "Mike"
End If
End Sub

You also need to make sure you have the spelling of the fields *exact*. "DropDown2" is not the same as "Dropdown2" which is the default capitalization Word uses.
 
Upvote 0

Forum statistics

Threads
1,225,286
Messages
6,184,072
Members
453,210
Latest member
GravyG_123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top