Exclude From BOM Toggle Macro

I'm trying to write a Macro that when you select a part within an assembly you can run the Macro to toggle weather the part is excluded from the BOM in all configurations. This is the code that I have gotten so far.

 

Sub main()
'declare solidworks interface
Dim swApp As SldWorks.SldWorks
Set swApp = Application.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swModel = swApp.ActiveDoc

'error checking
If swModel Is Nothing Then
       MsgBox "No active document found."
       Exit Sub
   End If
   
   If swModel.GetType <> swDocASSEMBLY Then
       MsgBox "Active document is not an assembly."
       Exit Sub
   End If

'declare component interface
Dim swPart As SldWorks.Component2
Set swPart = swModel.SelectionManager.GetSelectedObjectsComponent3(1, 0)

'check if part is excluded and include if so
If swPart.GetExcludeFromBOM2(swThisConfiguration, Nothing) = True Then
   
   Exit Sub
   
'Else
   
   'Exit Sub
End If

End Sub

 

My Problem right now is in the If statement "If swPart.GetExcludeFromBOM2(swThisConfiguration, Nothing) = True Then" It is saying that I have a type mismatch.

 

Is Anyone able to help with this problem, Thanks