Link a Word Dropdown Content Control to a Table Using VBA
Question details
Populate a Word dropdown content control with document names stored in a table.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A document contains a table of document names and a dropdown where a reader can select one name.
- Observed behavior
- The dropdown should contain entries read from the table when the VBA macro is run.
Open the document in desktop Word and make sure the Developer tab is available. Use a simple, unmerged, one-column table with one document name per row; the example reads every row of Table 1, including any header.
Populate the Word dropdown from a table with VBA
Use this method to fill one or more dropdown content controls from the first table in the active document.
The macro preserves the first dropdown list entry as a placeholder, removes the remaining entries, and adds unique, nonblank names from the table. Run it again after changing the table; the list does not update automatically.
On the Developer tab, select Drop-Down List Content Control. Select the control, open Developer > Properties, and set its Title to Document List. Under Drop-Down List Properties, add a first entry such as Select a document to keep as the placeholder.
Open Developer > Visual Basic, choose Insert > Module, and paste this code into the module: Sub PopulateDocumentDropdown() Dim cc As ContentControl Dim tableRow As Row Dim entry As ContentControlListEntry Dim itemText As String Dim i As Long Dim found As Boolean Dim matched As Long If ActiveDocument.Tables.Count < 1 Then MsgBox "The document does not contain a table." Exit Sub End If For Each cc In ActiveDocument.ContentControls If cc.Type = wdContentControlDropdownList And cc.Title = "Document List" Then matched = matched + 1 If cc.DropdownListEntries.Count = 0 Then cc.DropdownListEntries.Add Text:="Select a document", Value:="Select a document" End If For i = cc.DropdownListEntries.Count To 2 Step -1 cc.DropdownListEntries(i).Delete Next i For Each tableRow In ActiveDocument.Tables(1).Rows itemText = tableRow.Cells(1).Range.Text itemText = Trim$(Left$(itemText, Len(itemText) - 2)) If Len(itemText) > 0 Then found = False For Each entry In cc.DropdownListEntries If StrComp(entry.Value, itemText, vbTextCompare) = 0 Then found = True Exit For End If Next entry If Not found Then cc.DropdownListEntries.Add Text:=itemText, Value:=itemText End If End If Next tableRow End If Next cc If matched = 0 Then MsgBox "No dropdown titled Document List was found." End Sub
In the Visual Basic editor, change ActiveDocument.Tables(1) to the appropriate table number if the document names are not in Table 1. If the table has a header, remove it from the source table or adjust the loop so the header is not added.
Save the document as a Word Macro-Enabled Document (.docm), then select Developer > Macros, choose PopulateDocumentDropdown, and click Run. Open the dropdown in the document to check the entries.

Edit Word Documents with WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface for editing documents and moving between Office-compatible files. The Word-specific VBA solution above must be completed in Microsoft Word.

Frequently Asked Questions
Why does the macro say it cannot find the dropdown?
Select the dropdown and open Developer > Properties. Its Title must exactly match Document List, or you can change the title checked in the macro to match your control.
How do I use a table other than Table 1?
In Developer > Visual Basic, find ActiveDocument.Tables(1) in the macro and replace 1 with the source table's position in the document.
Will the dropdown update when I edit the table?
No. After changing the table, select Developer > Macros and run PopulateDocumentDropdown again to rebuild the list.
Can readers select more than one document from the dropdown?
No. A Word dropdown content control supports one selection. A VBA UserForm with a multi-select list is an alternative for multiple selections.
Why must I save the document as a DOCM file?
A Word Macro-Enabled Document (.docm) can retain the VBA macro. Use File > Save As and select that format; run macros only when you trust the document and its code.




