QuitDoc shutting down SW?? is this right?

Hi,

I am having a problem keeping the SW application open.

My problem is isolated to the following VB function. I open a part file and everything is fine .. but when I close the file, SolidWorks exits!

I want to open & close files repeatedly, but can't seem to keep SW open. Can anybody point out what I am doing wrong? I am new to SW and expect I may be doing something stupid.

Thanks, John MacIntyre VC++ / VB / ASP / Database Developer

formatting link

----------------------------------------------------------------------------

------------------ Option Explicit

Sub Main() On Error GoTo ERR_HANDLER Const swDocPART = 1 Const sFileName = "MyTestPart.SLDPRT" Dim oApp As SldWorks.SldWorks Dim oDoc As SldWorks.ModelDoc2

Set oApp = New SldWorks.SldWorks oApp.Visible = True

Set oDoc = oApp.OpenDoc(sFileName, swDocPART) Debug.Print "Properties for " & sFileName Debug.Print vbTab & "Title :" & oDoc.SummaryInfo(0) Debug.Print vbTab & "Subject :" & oDoc.SummaryInfo(1) Debug.Print vbTab & "Author :" & oDoc.SummaryInfo(2)

Set oDoc = Nothing oApp.QuitDoc sFileName '

Reply to
John MacIntyre
Loading thread data ...

John,

That's a weird one, sounds like a bad install. Did you have anti-virus running when you installed SW ?

Mark

Reply to
Mark Mossberg

Just made this:

formatting link
the challenge was to make a "twisted loft" between 2 profiles. Guide curves don't allow this. Is there a need for an add-in here ?

Reply to
Philippe Guglielmetti

read the remark in apihelp.chm: " If you are closing the only document in the SolidWorks session and this SolidWorks session is a background session, then calling SldWorks::CloseDoc or this method results in the SolidWorks session being closed. " a "background session" is a SW session that was started by opening a SW document rather that explicitely starting SW.

Reply to
Philippe Guglielmetti

Just made this:

formatting link
the challenge was to make a "twisted loft" between 2 profiles. Guide curves don't allow this. Is there a need for an add-in here ?

Reply to
Philippe Guglielmetti

Thanks Philippe,

But isn't my example explicitly starting SW? Set oApp = New SldWorks.SldWorks

If not, how would I explicitly open it in VB?

Thanks in advance, John MacIntyre VC++ / VB / ASP / Database Developer

formatting link

SldWorks::CloseDoc

Reply to
John MacIntyre

John, if you use the Set oApp = New SldWorks.SldWorks line then you need to have a dummy document that doesn't get closed as Philippe mentioned. If you don't want to do this, you can use the CreateObject() method.

Best Regards,

Reply to
Robert V. Hanson

IIRC, there is a bit easier way to prohibit SW from closing...

Set swApp = New SldWorks.SldWorks swApp.UserControl = True

Refer to API help, swApp::UserControl

Hope this helps!

-h-

Reply to
Heikki Leivo

That worked great.

Thanks a lot for the help everyone. ... I really appreciate it.

Regards, John MacIntyre VC++ / VB / ASP / Database Developer

formatting link

Reply to
John MacIntyre

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.