combo box- drop down list

  • Thread starter Thread starter MEME
  • Start date Start date
M

MEME

Hi,

I have very little experience in programming.
I'm trying to assign values to a drop down list (combo box)
How you I do it?

Thanks
 
First, I'm assuming that you have a combo box from the Control Toolbox
and not the dropdown from the Forms toolbar -- they're completely
different. The Forms dropdown doesn't require any programming
(although you can use a macro to set one up, it isn't necessary).

You need to make a template for your document. In the template, you
have to write macros in the ThisDocument module named Document_New
(which runs automatically when a document is created from the
template) and Document_Open (which runs automatically when an existing
document based on the template is re-opened). In each of those macros,
you need code to add items to the combo box's list. It could look
something like this:

Private Sub Document_New()
Populate ComboBox1
End Sub

Private Sub Document_Open()
Populate ComboBox1
End Sub

Sub Populate(cbo As MSForms.ComboBox)
With cbo
.AddItem "one"
.AddItem "two"
.AddItem "three"
.ListIndex = 0
End With
End Sub

Of course, you would replace the items in parentheses with the text
you want in the list. You can add as many as you want. Also, it's a
good idea to replace the default name of the combo box (ComboBox1)
with something that reflects what the list is used for.

A more complex method, but better for large amounts of data, is shown
at
<http://msdn2.microsoft.com/en-us/library/aa140269(office.10).aspx>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top