how to edit a combo box or how to insert items in a combo box?

M

Mo

i have created a combo box in a word doc. i would like to enter some items in
it.

for example, i would like to be able to choose my items from a drop down
menu. i don't wish to use any code as i am not a Programmer.

can you assist please.

Thank you
 
J

Jean-Guy Marcil

Mo was telling us:
Mo nous racontait que :
i have created a combo box in a word doc. i would like to enter some
items in it.

for example, i would like to be able to choose my items from a drop
down menu. i don't wish to use any code as i am not a Programmer.

can you assist please.

How did you create this combo box? (What command/toolbar did you use?)
What is your overall purpose with this combo box?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
M

Mo

Jean,

thanks for replying.

i have used the control box to create the combo box.
i would like to enter items in there & select them up via the drop down menu.

hope this clarifies your questions.

Thank you
 
J

Jean-Guy Marcil

Mo was telling us:
Mo nous racontait que :
Jean,

thanks for replying.

i have used the control box to create the combo box.
i would like to enter items in there & select them up via the drop
down menu.

hope this clarifies your questions.

Actually, it clarifies your post... not my questions! ;-)

Here is a simple way:
While in design mode, right click on the combobox and select "View Code".
Once in the code pane, paste the first example and play around with it in
the document to see what happens.
This is fine if you only have a few items. If you have many items, you may
want to consider using an array, see the second example for that.

'_______________________________________
'Example One
Private Sub ComboBox1_GotFocus()

Dim lngCurSel As Long

With ComboBox1
'Save Current selection
lngCurSel = .ListIndex
'Remove items or we will keep adding them over an over...
.Clear
'Add the items
.AddItem "Select"
.AddItem "One"
.AddItem "Two"
.AddItem "Three"
.AddItem "Four"
'Reset the selection
.ListIndex = lngCurSel
End With

End Sub
'_______________________________________

'_______________________________________
'Example Two
Private Sub ComboBox1_GotFocus()

Dim varItems As Variant
Dim lngCurSel As Long

'Create the array
varItems = Array("Select", "One", "Two", "Three", "Four", "Five", _
"Six", "Seven", "Eight", "Nine", "Ten")

With ComboBox1
'Save Current selection
lngCurSel = .ListIndex
'Remove items or we will keep adding them over an over...
.Clear
'Add the items
.List() = varItems
'Reset the selection
.ListIndex = lngCurSel
End With

End Sub
'_______________________________________

If I may add a comment, if you plan on distributing your template/document,
avoid the ACtiveX controls from the Control Toolbox.
In Word they are unstable and if someone has their security set to High,
they will be deactivated as they are considered a virus threat (They can
activate code just by being clicked on...)

See if you can use a protected form instead.

Of course, if your projects requires macros anyway, then the security issue
becomes irrelevant. Just be aware that there have been numerous reports
describing difficult to cure problems regarding ActiveX controls. I think
three things can help you:
1) Make sure you give them a name yourself (Do not use the default name as I
did above with "ComboBox1",
2) Do not use too many of tem in one document,
3) Create the document using the lowest Word version you want to support.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
M

Mo

Jean,

Thanks for your help. It has worked.
I might need to post another question for you again.

Regards,

Mo
 
S

Selamet Gan

Jean-Guy Marcil said:
Mo was telling us:
Mo nous racontait que :


How did you create this combo box? (What command/toolbar did you use?)
What is your overall purpose with this combo box?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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

Top