TroyPilewski
TroyPilewski

Reputation: 369

Add items to drop-down list Word 2010

I created a document and added a drop-down list content control in Microsoft Word 2010. How would I select this object and add items to it via VBA? An exhaustive search has led to being able to add one and add items, but I want to know how to add items to a list already on the document.

Also, is it possible to change the extension of a Microsoft Word 2010 document to (.zip) and add in an XML file. This XML file would house all the items to be added to the drop-down content control.

Upvotes: 1

Views: 2724

Answers (1)

Alex Butenko
Alex Butenko

Reputation: 3774

Something like

For Each item In ActiveDocument.ContentControls
    If item.Title = "DropDown1" Then
        item.DropdownListEntries.Add Text:="Item1", Value:="Item1"
        item.DropdownListEntries.Add Text:="Item2", Value:="Item2"
        Exit For
    End If
Next

You can find it by title or tag. Or by type - if it is only one dropdown in the document.

Upvotes: 2

Related Questions