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
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
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.
RE: Launching SolidWroks from the Command Line
http://support.microsoft.com/default.asp...
RE: Launching SolidWroks from the Command Line
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
Janet