I have some VBA code in Excell. How do I check that SW is alredy open or not?
API: How do I check from VBA that SW is not running?
May 15, 2004
3 Replies
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
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required