How could I get the assembly component’s active configuration? (swx2009)

Hi,

I have an assembly, and it contains some components.

I would like to get a selected component’s active configuration (as it builded in the assembly)

Here is my code below, but at the last line it stopped with error. What is wrong, and the right way?

Thanks

Sub main()

Dim SelMgr As SelectionMgr

Dim swComp As SldWorks.Component2

Dim swModelPart As ModelDoc2

Set swApp = Application.SldWorks

Set swMainAsmDoc = swApp.ActiveDoc

Set SelMgr = swMainAsmDoc.SelectionManager

boolstatus = swMainAsmDoc.Extension.SelectByID2("COMPONENTNAME", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)

Set swComp = SelMgr.GetSelectedObject6(1, 0)

Set swModelPart = swComp.GetModelDoc2

numConfigs = swModelPart.GetConfigurationCount

ConfigNames = swModelPart.GetConfigurationNames

Activeconfig = swModelPart.GetActiveConfiguration

End Sub

SolidworksApi macros