Get components name from an assembly in a specific order VBA

Hi, everybody!

I have the below code in order to get the name (including the instance ID) of the components of an assembly!

It's working well. However, it doesn't have any order to get the components of the assembly!!

For example, It be great if the first gotten compoent would be the first component of the feature manager.

Does anybody know how to get this information in a organized way or even how this custon logic works?

Thanks!

Sub main()

Dim swApp As SldWorks.SldWorks

Dim Ass As SldWorks.AssemblyDoc

Dim Comp As Variant

Dim swComp As Component2

Set swApp = Application.SldWorks

Set Ass = swApp.ActiveDoc

Comp = Ass.GetComponents(True)

For i = 0 To UBound(Comp)

        Set swComp = Comp(i)

MsgBox (swComp.Name2)

Next

End Sub

SolidworksApi macros