I have some VBA code in Excell. How do I check that SW is alredy open or not?
- posted
19 years ago
I have some VBA code in Excell. How do I check that SW is alredy open or not?
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"
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.
Dim swApp as sldworks.sldworks set swApp=sldworks.sldworks If not swApp=Nothing Then (sw not running!) End if
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.