ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
KRKeith Rice17/11/2009

I have an interesting dilemma that hopefully has an easy solution.  My PDM trigger, which occurs during a drawing check in, works just fine when invoking a stand-alone .exe like Notepad.  The stand-alone program I wrote, which saves out the active drawing document as an eDrawings document, also operates fine when executed normally.  (That is, it saves the eDrawing in the proper folder, no problem.)  But when I try to invoke my stand-alone .exe through the trigger I get a Microsoft .NET framework error that says, "Unhandled exception has occurred in your application ... Object reference not set to an instance of an object."  I have attached a .jpg showing the full error.

Any ideas how I can get the trigger to successfully invoke my .exe?  Here is the code in my exe:

Imports SolidWorks

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         Dim swApp As New SldWorks.SldWorks
         Dim swDoc As SldWorks.ModelDoc2

         swApp = CreateObject("SldWorks.Application")
         swDoc = swApp.ActiveDoc
 
         swDoc.SaveAs3("C:\test.edrw", 0, 0)

         Me.Close()
    End Sub
End Class

Also, what HTML tags do I need to use this forum to encapsulate my code?

Thank you for your help.