Could you give a screenshot of what you would want for the cells arrangement and content.
Also: Does your assembly has sub-assemblies?
Hello Fifi Riri
Thank you for your answer. Ok, I will try to explain you, what I want to do. On the first line, you can see the name of part of my assembly. And for each part, the macro extract all the mates (all line after the line 2), but for the moment we can't see with which part the part of cells one is in the constraint. I try to extract the name of mates and the name of the part with which the part of the first cells is in mates.
My assembly does not have sub-assemblies.
Ok. A quick fix would be to replace your "Select Case" with this:
Dim swComp As SldWorks.Component2
Set swComp = SingleMate.MateEntity(0).ReferenceComponent
If swComponent.Name2 = swComp.Name2 Then
Set swComp = SingleMate.MateEntity(1).ReferenceComponent
Dim MyComp As String
MyComp = swComp.Name2
'Debug.Print "Name of component: " & MyComp
Dim MyMate As String
Select Case typeOfMate
MyMate = "Coincident"
MyMate = "Concentric"
MyMate = "Perpendicular"
MyMate = "Parallel"
MyMate = "Tangent"
MyMate = "Distance"
MyMate = "Angle"
MyMate = "Unknown"
MyMate = "Symmetric"
MyMate = "Other"
Debug.Print MyMate & " - " & MyComp
xlWs.cells(x, y).Value = MyMate & " - " & MyComp
Hello again Fifi Riri
Thank you very much, my macro works very well.