Macro to Launch an executable

  • Thread starter Thread starter Jasper Recto
  • Start date Start date
J

Jasper Recto

I need to make a macro that will launch an executable. I want to attach it
to a button so clicking the button will launch another program.

Is this possible?

Thanks,
Jasper
 
Can you give more details of what you're trying to do ?
What program are you wanting to run ?
Do you want the program to do something on open
etc
 
The program is a small custom program we had created. All I want to do is
launch it. The file is called BOM.exe.

I just want to add the macro to a switchboard so I can keep it with other
related options on that switchboard.

Thanks,
Jasper
 
Jasper,

The method below will work. It may also be possible to call BOM.exe
directly in the subroutine cmdRunBOM_Click() with the line "RunJob "BOM.exe"
but you would have to experiment with that.


1) Create a BATCH file (with NOTEPAD) called RUNBOM.BAT - for the purpose of
this example I assume you will put it in C:\BATCH

Batch file needs one line (you may need to specify the path):

C:\[whatever location BOM.exe is in]\BOM.EXE

2) Then copy these two routines to your VBA module:

Private Sub cmdRunBOM_Click()
RunJob "C:\BATCH\RUNBOM.BAT"
End Sub

Sub RunJob(Command As String)

Dim varProc As Variant

varProc = Shell(Command, 6)

End Sub

3) Then the event "on click" for your button is the subroutine:
cmdRunBOM_Click()
 
THANKS!
dhstein said:
Jasper,

The method below will work. It may also be possible to call BOM.exe
directly in the subroutine cmdRunBOM_Click() with the line "RunJob
"BOM.exe"
but you would have to experiment with that.


1) Create a BATCH file (with NOTEPAD) called RUNBOM.BAT - for the purpose
of
this example I assume you will put it in C:\BATCH

Batch file needs one line (you may need to specify the path):

C:\[whatever location BOM.exe is in]\BOM.EXE

2) Then copy these two routines to your VBA module:

Private Sub cmdRunBOM_Click()
RunJob "C:\BATCH\RUNBOM.BAT"
End Sub

Sub RunJob(Command As String)

Dim varProc As Variant

varProc = Shell(Command, 6)

End Sub

3) Then the event "on click" for your button is the subroutine:
cmdRunBOM_Click()


Jasper Recto said:
I need to make a macro that will launch an executable. I want to attach
it
to a button so clicking the button will launch another program.

Is this possible?

Thanks,
Jasper
 
Back
Top