Hi all
I'm trying to use a comboBox (drop-down list of choices) in a userform on solidworks, but I can't do it.
I know how to do it for excel, by choosing a list in a column, but I don't want to have to use a file next to my macro.
I thought I could use:
ComboBox1.AddItems ("Choice1")
ComboBox1.AddItems ("Choice2")
But it doesn't work.
Anyone have an idea please
Maclane
2
Hello;
Try:
Userform1.ComboBox1.AddItem "choice1"
Userform1.ComboBox1.AddItem "choice2"
…
or '''
userform1. ListBox1.List = Array("foo", "foo", "tutu")
comme sous vba quoi....
Cordialement.
1 Like
Sylk
3
Hello
To populate the combobox when loading and set a default choice, you need to place it in UserForm_Initialize():
With ComboBox1
.AddItem "Choix 1"
.AddItem "Choix 2"
.AddItem "Choix 3"
.ListIndex = 0
End With
Then to read the option selected by the user:
If ComboBox1.ListIndex = 2 Then ...
or better:
Select Case ComboBox1.ListIndex
Case 0: expression
Case 1:
expression
expression
Case Else: expression
End Select
2 Likes