I've been beating my head into a wall to try to figure out how to get a combobox userform to work in the SW VBA environment. I might have to ask for complete guidance on everything I want to do, but for now I'll try to do it myself. I'm completely new to VBA userforms so I might be missing something obvious.
Here is what the userform is supposed to look like at the moment. The items are for example only.
Private Sub CommandButton1_Click()
If Me.ComboBox1.ListIndex = -1 Then
MsgBox "A value is required for the material. Ending macro. Please try again."
Me.ComboBox1.SetFocus
Cancel = True
Unload Me
End
End If
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim selectedItem1 As Object
Me.ComboBox1.AddItem "Aluminum"
Me.ComboBox1.AddItem "Mild (Carbon) Steel"
Me.ComboBox1.AddItem "Stainless Steel"
Me.ComboBox1.AddItem "Aluminum .020"
Me.ComboBox1.AddItem "Aluminum .020"
Me.ComboBox1.AddItem "Aluminum .020"
Me.ComboBox1.AddItem "Aluminum .020"
Me.ComboBox1.AddItem "Aluminum .020"
Me.ComboBox1.AddItem "Aluminum .020"
selectedItem1 = ComboBox1.SelectedItem
For i = 0 To 8
If selectedItem1.ToString() = i Then
MsgBox "Successful SelectedItem run test"
End If
Next i
End Sub
I am having problems with line 29. I get a error as shown below.
All of the examples I've been able to find use the syntax as I've written it, at least as far as I can tell. Is this some sort of reference issue?
SolidworksApi/macros