Macro to launch an external programme

Feb 23, 2007 3 Replies

Is there a Macro that will launch a specified external programme?



John Layne

formatting link


If you have a short-cut for the program you want to start, you can in its properties assign a shortcut-key to launch, which would actually make it easier than making a macro in SW and a button to push.

I have it for launching out old customized toolworks, "ctrl+alt+T"

You might use the "ShellExecute" command. It is not immediately available in VBA. You need to use Windows API to set up these calls. "ShellExecute opens a file with its default program.

There is an example of this in one of my publicly available macros "CopyCustomInfo". I use ShellExecute to open the link to my website from the user interface.

' 'put this in the general declarations section of your macro ' 'ShellExecute API Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

' 'example of a Sub using "ShellExecute" ' Public Sub OpenEsoxWeb() ShellExecute 0, vbNullString, "

formatting link
",vbNullString, "C:\", 1 End Sub

Look up SolidWorks API Help for the SHELL command. It's very easy stuff.

Matt

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required