Link to home
Start Free TrialLog in
Avatar of Jim Schwetz
Jim Schwetz

asked on

How do I get this drop down box to work.

Trying to create a dynamic drop down list in Word using VBA
MO Word 2013 Windows 7 Enterprise
Currently, when I click in the first drop down, nothing happens.  The first option shows, but I am not able to change it.  the second drop down is blank.
I thought I would be able to click in the first drop down, then select one of the four values.
I am using Legacy Drop Down Form Field.
using this as a tutorial:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_winother/drop-down-menu-in-word/1d4ce90e-f561-445f-9481-c7eab9493386
Here is my Word Doc with 2 drop downs.  
This is just to learn it, my actual project will be for the user to use many drop downs and the values will create a letter that can be sent to the client.  So depending on what the user selects, will populate the word document.  I could have used Adobe Pdf with javascript, but then I would be the only one who could update it.  I thought with word, the user could update any content themselves.  but I am open to other platforms.
User generated imageUser generated image
Sub PopulateddState()
    Dim MyCase As String
    MyCase = ActiveDocument.FormFields("ddRegion").Result
    Select Case MyCase

    Case "North"
        With ActiveDocument.FormFields("ddState").DropDown.ListEntries
            .Clear
            .Add "Michigan"
            .Add "Ohio"
        End With
    Case "South"
        With ActiveDocument.FormFields("ddState").DropDown.ListEntries
            .Clear
            .Add "Georgia"
            .Add "Texas"
        End With
    Case "East"
        With ActiveDocument.FormFields("ddState").DropDown.ListEntries
            .Clear
            .Add "New York"
            .Add "Maine"
        End With
    Case "West"
        With ActiveDocument.FormFields("ddState").DropDown.ListEntries
            .Clear
            .Add "California"
            .Add "Oregon"
        End With
    End Select
 End Sub

Open in new window

Doc3.docm
Avatar of Kimputer
Kimputer

Usually it's better to attach the word document here, tracking errors will be MUCH faster.
Avatar of Jim Schwetz

ASKER

Thanks Kimputer, I just added it.
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Norie,  No i did not, I figured that just needed to be done before others could use it.  I did not even think of trying that.  I will try that now.
I now have my drop down functionality.   Wow, I guess I should have at least tried that before asking.  Thanks Norie and Kimputer
Thanks for the fast answer,  I did not realize that the restricted had to be on to test it.  Thanks