An error has occurred and SolidWorks needs to restart

Hi,

I have problems with an EPDM Add-In I'm currently working on.

When a SLDPRT document is open in SolidWorks, checked out, and a user push the checkin button in SolidWorks I wish to close the document.

I have this code triggered from the postunlock event.


Dim oFile As EdmLib.IEdmFile5

Dim oSwApp As SldWorks.SldWorks

oFile = Ovault.GetFileFromPath(ppoData(Lindex).mbsStrData1)

oSwApp = CreateObject("SldWorks.Application")

oSwApp.CloseDoc(oFile.Name)

The document does close but after a few seconds SolidWorks crash and a message is displayed saying SolidWorks needs to restart.

If I checkin the document from the explorer instead of from SolidWorks, everything works just fine.

I'm using Vista 32bit, EPDM 2011sp2 and SW 2011sp2.
 

Has anyone any idea what could be wrong?

Thanks in advance

SolidworksApi macros