Getting Components other than suppressed from the assembly treee

Hello,

I am trying to get the parts from the assembly tree that are unsuppressed. Can you guys help with the mistake. I am fairly new and I am learning.

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swFeat As SldWorks.Feature

Dim testModel As Component2

Dim entity As entity

Dim component As Component2

Sub main()

 

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

 

    Set swFeat = swModel.FirstFeature

   

    While Not swFeat Is Nothing

            Set testModel = swFeat.GetSpecificFeature2

            If testModel.GetSuppression = 0 Then

                MsgBox "Part Suppressed"

            Else

                Set entity = swFeat

                If entity.GetType = swSelectType_e.swSelCOMPONENTS Then

                    Set component = swFeat.GetSpecificFeature2

                    MsgBox "Name: " & component.Name2

                End If

            End If

           

            Set swFeat = swFeat.GetNextFeature

    Wend

End Sub

The bold sentence is where I am getting an error.

Thank you,

SolidworksApi macros