# MS Word (VBA combobox control list properties)



## seshu79 (Aug 18, 2008)

Hello,


I got this work of questionaire from my HR Manager, Deputy, I wanted to put some data in the combobox for option selection but I do not know how exactly?

I tried to google search it but I could not find any good result, I ask for help of anybody who know how to do it?

-Ramakandra
HR Inspector


----------



## yrona (Aug 15, 2008)

It really depends on whether or not the combo box is linked to a data source or not.

Assuming that it is not, you can add options using VBA. Let us assume that the form containing the combo box is UserForm1, and that the ComboBox is assigned the name ComboBox1. 

Then, you need the following code snippet to initialize the combo box. In this example the code is included in the subroutine run whenever the form is constructed for the first time:


```
Private Sub UserForm_Initialize()

    ComboBox1.Clear   'This removes previous entries. Of course, if you want to keep what's already there, leave out this step
    Call ComboBox1.AddItem("Item 1")   'This row is assigned key value of 0
    Call ComboBox1.AddItem("Item 2")   'This row is assigned key value of 1
    Call ComboBox1.AddItem("Item 3")   'This row is assigned key value of 2
    'You can add however many entries you want.         
End Sub
```
if you want to edit items or remove them, the commands are simple;

```
ComboBox1.List(1, 0) = "New Item 2"  'Edits column 0 of the row with the key value of 1
    
    ComboBox1.RemoveItem (2)             ' Removes the row with the key value of 2
```


----------



## seshu79 (Aug 18, 2008)

yrona said:


> It really depends on whether or not the combo box is linked to a data source or not.
> 
> Assuming that it is not, you can add options using VBA. Let us assume that the form containing the combo box is UserForm1, and that the ComboBox is assigned the name ComboBox1.
> 
> ...


Yrona, thank you for your reply. This is informative. I only like to put data on combobox not to connect to specific source (database) using ActiveDocument (not in UserForm)?

When can I expect to hear from you?

Cheers !!

-Ramakandra
HR Inspector


----------



## seshu79 (Aug 18, 2008)

F1 QUALIFICATION QUESTIONS FOR FOREIGNERS (the actual file)


----------



## yrona (Aug 15, 2008)

Ah. You can add values to the combo-boxes embedded as form fields quite easily.

Unprotect the document, double click on the combo box and in the dialog box that opens enter in the additional options.

Then you reprotect the document, and people can start using it as a form.


----------



## seshu79 (Aug 18, 2008)

Hello,

I have received your message. I made an video for exactly where to put the data in combobox.

Cheers!

-Ramakandra
HR Inspector


----------

