×
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

Launching SolidWroks from the Command Line

Launching SolidWroks from the Command Line

Launching SolidWroks from the Command Line

(OP)
Is there a way to launch SolidWorks from the command line? I have an Access database with lists of drawing files in it. I want to be able to have a user click on the drawing name and have solidworks open the file automatically.
My VBA code currently looks like this:

Private Sub DrawingName_DblClick(Cancel As Integer)
'Open solidworks with the appropriate drawing
    strFilename = Me.DrawingFile
    x = Shell(strFilename, 1)
End Sub

But I get an error message that says "invalid file or procedure call." The file name variable contains the full path information. Can anyone tell me what I am doing wrong or make suggestions?

Thanks,
Janet

RE: Launching SolidWroks from the Command Line

As I understand it, shell is used to activate applications.

I once saw some code to open a file with its default application, but I can't seem to find it.  If I run across it I will post.

In the meantime, try using shell to open the SW, then access the SW application object via CreateObject and use it to open the file via SW API.

All this machinery making modern music can still be open-hearted.

RE: Launching SolidWroks from the Command Line

Yes, that's the one.  If you use the "Open" verb as its verb parameter, ShellExecute will use the same command-line type of default behavior that you get when you do a right-click Open on the filename from Windows Explorer.  (You can see the syntax for these command lines in the registry)

Remember to declare the functions you will be using:
    Private Declare Function ShellExecute Lib "shell32.dll" Alias _
      "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
      String, ByVal lpszFile As String, ByVal lpszParams As String, _
      ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    
    Const SW_SHOWNORMAL = 1
 
And then you can make use of the function something like this:
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", sDocName, "", "C:\", SW_SHOWNORMAL)

Regards,
Brenda   

RE: Launching SolidWroks from the Command Line

(OP)
That worked perfectly. Thank you both very much!

Janet

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