As shown in the screenshot on the left, how can you limit the choices in the second drop-down list based on the selection in the first drop-down list? This article will guide you on how to create dependent drop-down lists in a Word document.
Create dependent drop-down lists in Word using VBA code
The VBA code below can help you create dependent drop-down lists in a Word document. Please follow the step-by-step instructions.
- Developer > Legacy Forms > Drop-Down Form Field. See screenshot:
- Properties. See screenshot:
- In the opened Drop-Down Form Field Options dialog, you need to:
3.1 Enter categories into the Drop-Down Item box and click Add, repeat the operation until all categories are added to the Items in Drop-Down List box.
3.2 Enter “ddfood” into the Bookmark box.
3.3 Click OK. See screenshot:
Right-click on the second drop-down list, click Properties to open the Drop-Down Form Field Options. See screenshot: OK and click the Bookmark button to enter ddCategory in the dialog box.
- Press Alt + F11 to open the Microsoft Visual Basic for Applications window.
- In the Microsoft Visual Basic for Applications window, click Insert > Module, then copy the VBA code below into the Module window.