API: How do I check from VBA that SW is not running?

I have some VBA code in Excell. How do I check that SW is alredy open or not?

Reply to
Loading thread data ...

The following snippet will tell you (assuming you DIMmed "swapp" to either an Object oi SldWorks.SldWorks. Note that there is an empty parameter before "Sldworks.application". If you replace that with an empty string, ie, Set swapp = GetObject("", "Sldworks.application"), then a new instance of SW will be created if it is not running.

On Error Resume Next Set swapp = GetObject(, "Sldworks.application") On Error GoTo 0 if swapp is nothing then msgbox "Solidworks is not running"

Reply to

If you dig around in API help there is a whole section on how to tell if SW is running, not running, running silently, etc.

Reply to

Dim swApp as sldworks.sldworks set swApp=sldworks.sldworks If not swApp=Nothing Then (sw not running!) End if

Reply to
Evan T. Basalik

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.