Hi,
I'm fairly new to the SolidWorks API and am having a heck or a time with it.
The problem I am currently having, is when a user creates a new file, a dialog box opens for user interaction. But if the user cancels, I need to close the newly created file.
I thought the FileNewNotify2 event was the way to go, but for the life of me I cannot close that file! and to be honest, I don't find the API Documentation all that helpful.
This has got to be something simple, can somebody provide me with a clue?
Thanks in advance, John
----------------------------------------------------------------------------
--------------
---- CancelTest.cls -- CancelTest.cls -- CancelTest.cls -- CancelTest.cls -- CancelTest.cls --
----------------------------------------------------------------------------
-------------- Option Explicit
Implements SWPublished.SwAddin Private WithEvents m_oSldWrks As SldWorks.SldWorks
Private Function m_oSldWrks_FileNewNotify2(ByVal newDoc As Object, _ ByVal DocType As Long, _ ByVal templateName As String) As Long '// open a dlg box
'// if dlg box was cancelled, then close new file Dim sTitle As String sTitle = newDoc.GetTitle() '// newDoc is assumed to be a SldWorks.PartDoc Debug.Print sTitle m_oSldWrks.QuitDoc sTitle '// doesn't work m_oSldWrks.CloseDoc sTitle '// doesn't work
End Function
Private Function SwAddin_ConnectToSW(ByVal ThisSW As Object, _ ByVal Cookie As Long) As Boolean '// set data member object Set m_oSldWrks = ThisSW End Function
Private Function SwAddin_DisconnectFromSW() As Boolean '// clear data member object Set m_oSldWrks = Nothing End Function