Open MS Word
Right-click the toolbar & select 'Control Toolbox'
Double-click 'ComboBox' (its added to your project)
Right-click the combobox on the form & choose PROPERTIES
Under NAME choose 'cboNames' (cbo is the prefix used in programming to
represent a combobox)
Right-click the control & choose 'View code'
In the right-hand pane, you'll see two drop down lists. In the left one
choose DOCUMENT & in the right one choose choose OPEN (some code shows below):
Private Sub Document_Open()
End Sub
In between the Sub/End Sub, paste in the following code:
With cboNames
.AddItem ("Sarah")
.AddItem ("Sue")
.AddItem ("Peter")
.ListIndex = 0
End With
Now, your code should look like this:
Private Sub Document_Open()
With cboNames
.AddItem ("Sarah")
.AddItem ("Sue")
.AddItem ("Peter")
.ListIndex = 0
End With
End Sub
The list index property will list Sarah as the selected item in the list.
VBA/VB is 0 (zero) based. Therfore, the first item is 0, second item is 1 and
so on.
Click the green triangle to run (F5) the above code & you should have a
working combobox.
I hope this helps