×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Code to Determine if SolidWorks is Open

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
 

RE: Code to Determine if SolidWorks is Open

Look at the Task Manager.

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

I had created something like that a while back.  It went something like this.  I haven't used it in a while, and I don't remember exactly what my purpose was, but I think it worked.

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

(OP)
Thanks gopack13.  That's exactly what I needed.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources