Code to Determine if SolidWorks is Open
Code to Determine if SolidWorks is Open
(OP)
Hi,
I would like to be able to run a macro with or without SolidWorks being open. How do you write an if statement to determine if SW is running and then open it if it is not? As a guess, I tried:
Set swApp = GetObject(, "SldWorks.Application")
If swApp Is Nothing Then
Set swApp = CreateObject("Sldworks.Application")
swApp.Visible = True
End If
I would like to be able to run a macro with or without SolidWorks being open. How do you write an if statement to determine if SW is running and then open it if it is not? As a guess, I tried:
Set swApp = GetObject(, "SldWorks.Application")
If swApp Is Nothing Then
Set swApp = CreateObject("Sldworks.Application")
swApp.Visible = True
End If






RE: Code to Determine if SolidWorks is Open
Chris
SolidWorks/PDMWorks 08 3.1
AutoCAD 06/08
ctopher's home (updated Jul 13, 2008)
ctopher's blog
RE: Code to Determine if SolidWorks is Open
On Error Resume Next
Set swApp = GetObject(, "SldWorks.Application")
If Err.Number <> 0 Then
Set swApp = CreateObject("SldWorks.application")
swApp.Visible = True
Err.Clear
swNotOpen = True
End If
swApp.RunMacro "C:\Macro.swp", "Macro1", "main"
If swNotOpen = True Then
swApp.ExitApp
End If
RE: Code to Determine if SolidWorks is Open