Runtime error on new solid version

I have resently installed SolidWorks 2010 x64 (form solid 2009 x32) and I have encountered alot of probles with macros that ran in my previos version

The error I have trouble with now is "Runtime Error 2147417851 (80010105)". It is not consistent, i can run the macro most of the times but sometimes the error shows and solid shuts down. The row that stops the macro is:

bRet = swAssy.ReplaceComponents(partpath, "", replaceAll, replaceMates)

Any ideas on how to fix this? When I replace parts/assemblys I try to first replace with a part file and then with a assembly file (the user does not specify if the component is part or assembly) Can this cause the problem?

/Fredrik

SolidworksApi macros