InsertMateReference fails to work

I need some guidance. All the variables seem to be correct but it thows the error shown when it reaches "Set swNewMateFeature".

            swModel.ClearSelection2 True

            objMateObject(x, 1).Select4 False, Nothing  'Object is selected as anticipated

            Debug.Print lngEntityType(x, 1) 'Prints 2

            Debug.Print lngMateAlignment(x, 1) 'Prints 2

            objMateObject(x, 2).Select4 False, Nothing  'Object is selected as anticipated

            Debug.Print lngEntityType(x, 2) 'Prints 2

            Debug.Print lngMateAlignment(x, 2) 'Prints 1

            objMateObject(x, 3).Select4 False, Nothing  'Object is selected as anticipated

            Debug.Print lngEntityType(x, 3) 'Prints 0

            Debug.Print lngMateAlignment(x, 3) 'Prints 0

         

            Set swNewMateFeature = swFeatMgr.InsertMateReference _

            (strSortedNames(n), _

            objMateObject(x, 1), lngEntityType(x, 1), lngMateAlignment(x, 1), _

            objMateObject(x, 2), lngEntityType(x, 2), lngMateAlignment(x, 2), _

            objMateObject(x, 3), lngEntityType(x, 3), lngMateAlignment(x, 3))

Thanks,

Mike

SolidworksApi macros