PDA

View Full Version : ComboBox Additem Duplicates



PetarStan
04-13-2012, 01:28 AM
Hi

Im am doing a PowerPoint 2010 presentation where i want to have a dropdown combobox with the 4 different options.
My code looks accordingly:

Private Sub ComboBox1_DropButtonClick()
ComboBox1.AddItem ""
ComboBox1.AddItem "Passed"
ComboBox1.AddItem "Not Passed"
ComboBox1.AddItem "Follow-Up"

End Sub

However, my problem is that when i choose an option the dropdown list gets filled with the same options 3 times i.e. the options are trippled. (see attachment) Every time i choose an option the list gets extended further with the same options. How do i avoid this?
7852

would appreciate fast help

PetarStan
04-13-2012, 02:40 AM
I have figured it out now and my code now looks like this:
Private Sub ComboBox1_DropButtonClick()
If ComboBox1.ListCount < 4 Then
ComboBox1.AddItem ""
ComboBox1.AddItem "Passed"
ComboBox1.AddItem "Not Passed"
ComboBox1.AddItem "Follow-Up"
End If
End Sub

However, i now have another issue and that is I want to have a different text colour for each option i.e. Passed should be in green text, Not Passed in red and Follow-Up in blue. Is that possible and how can you do that?

Cosmo
04-13-2012, 05:18 AM
A better solution would be to clear the items before adding them

Combobox1.Clear
ComboBox1.AddItem ""
ComboBox1.AddItem "Passed"
ComboBox1.AddItem "Not Passed"
ComboBox1.AddItem "Follow-Up"

I don't believe the list items can have different formatting.