How to solve the Runtime Error? R6025

I run the macro in sw2009 no problem,but in SW2007sp5.0,theruntime error happend.The error was also in SW2008sp3.1.


How Can I to solve the Runtime Error? In SW2007sp5.0.

Look at the macro in attach files.SolidworksApi macros