Add these lines
Dim swFace As SldWorks.Face2
Set swFace = swAssy.SelectionManager.GetSelectedObject6(1, -1)
Set swAssy = swModel
And add this line
swAssy.AddMate5 swMateCOINCIDENT, 0, False, 0, 0, 0, 0, 0, 0, 0, 0, False, False, 0
Thank you for your input Deepak, I've adjusted my code like you said. However, it still throws up the same error when I run it; inside the assembly with a face of the floating part selected. 'Mate failed with an error code 0'.. Should I be adding the selected face in the boolean as well?
Your AddMate5 line is not complete. It should be:
Dim mateError As Long
swAssy.AddMate5 swMateCOINCIDENT, 0, False, 0, 0, 0, 0, 0, 0, 0, 0, False, False, 0, mateError
Try updating it and see if that works or not.
Ah, cheers Deepak, I also have seem to forgotten to type 'Plane' to make it a "Top Plane@" + AssemblyName.
Better get some sleep now..