Richard Kendrew

Loading Configuration from ComboBox

Discussion created by Richard Kendrew on Jan 2, 2020
Latest reply on Aug 12, 2020 by Deepak Gupta

I've set up some code that pops up a form when a specific model (assembly) is loaded which has a combobox dropdown listing all the assembly configurations. I'm struggling to complete the code to load the chosen configuration when the 'ok' button is clicked, if anyone can help.

Private Sub CommButtonGO_Click()

ConfigNames = swModel.GetConfigurationNames()
   
For i = 0 To ComboBox1.ListCount - 1   'For each config in list
    If ComboBox1.Selected(i) = True Then  'If selected
    swModel.ShowConfiguration2 ComboBox1.Value
        End If
    Next 'Get next config
End Sub

'-----------------------------------------------------------------

Private Sub UserForm_Initialize()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

ComboBox1.Clear

ComboBox1.List = swApp.GetConfigurationNames(swModel.GetPathName)

End Sub

Outcomes