VBA & Macro Problems

Create a Word VBA Combo Box to Insert a Selected Option

Rana GarciaRana Garcia Nov 18, 2026 870 views

Question details

Create a Word VBA UserForm with two combo box choices and insert the selected choice into a document.

Create a Word VBA Combo Box to Insert a Selected Option
Product
Microsoft Word VBA
Device & OS
not provided
Scenario
A UserForm lets a user choose between an in-person and a phone option, then click OK to populate a document or template.
Observed behavior
The selected combo box value should appear in the intended document location after the user clicks OK.
Before you start

Enable the Developer tab in Word and save the file as a macro-enabled document (.docm) or template (.dotm). Use macros only from a trusted source, and identify where the selected text should appear.

Solution 1Recommended

Insert the combo box selection into a tagged content control

Use a UserForm and a tagged content control to place one selected value at a specific location in the active document.

1
Add a content control

In the document, place the cursor where the answer should appear. On the Developer tab, insert a Plain Text Content Control, open Properties, and set its Tag to Location.

2
Create the UserForm

Open Developer > Visual Basic, select the document or template project, and choose Insert > UserForm. In the Properties window, name the form frmLocation, add a ComboBox named cmbLocation, and add a CommandButton named btnOK with the caption OK.

3
Add the choices

Open the form's code window and add this initialization procedure: Private Sub UserForm_Initialize() With cmbLocation .Clear .AddItem "in person" .AddItem "by phone" .MatchRequired = True End With End Sub

4
Insert the selected value

In the same form code window, add the OK button procedure: Private Sub btnOK_Click() Dim matches As ContentControls If cmbLocation.ListIndex = -1 Then MsgBox "Please select an option." Exit Sub End If Set matches = ActiveDocument.SelectContentControlsByTag("Location") If matches.Count = 0 Then MsgBox "The Location content control was not found." Exit Sub End If matches(1).Range.Text = cmbLocation.Value Unload Me End Sub

5
Run the form

In the VBA editor, choose Insert > Module and add: Sub ShowLocationForm() frmLocation.Show End Sub Return to the document, choose Developer > Macros, and run ShowLocationForm. Select an option and click OK.

Insert the combo box selection into a tagged content control
Target document: The code updates the first content control tagged Location in the active document. Keep the intended document active and make sure the control is not locked against editing.
Free Microsoft Office alternative

Edit Word documents with WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents, making it easy to move everyday document work between office suites. It does not fix Microsoft Word VBA issues, and VBA UserForm compatibility may vary.

Edit document text and reusable templates in WPS WriterOpen and save Microsoft Word formats such as DOCXUse a familiar interface for everyday document editingMove compatible documents between WPS Office and Microsoft Office
microsoft office alternative - wps office

Frequently Asked Questions

Why does the form say the Location content control was not found?

In the active document, select the content control and open Developer > Properties. Make sure its Tag is exactly Location and that the intended document is active when you run the macro.

Can I use a list box instead of a combo box?

Yes. Add a ListBox to the UserForm and populate it with AddItem in UserForm_Initialize. For a single-selection list box, check its ListIndex and use its Value in the OK button procedure. Multi-select list boxes require looping through the Selected items instead.

How do I prevent the user from submitting a blank choice?

In btnOK_Click, check whether cmbLocation.ListIndex is -1 before writing to the document. If it is, show a message and use Exit Sub so the form stays open.

Where should I save the VBA code?

Save the document as a Word Macro-Enabled Document (.docm) or the template as a Word Macro-Enabled Template (.dotm). Put the event procedures in the UserForm's code window and the ShowLocationForm macro in a standard module.