Link to home
Start Free TrialLog in
Avatar of kiwitoad
kiwitoad

asked on

question from a newbie (a real one)

i want to launch an external executable file (C:\start.exe)

how can i make this happen whith a command button?


ASKER CERTIFIED SOLUTION
Avatar of RoryR
RoryR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sanker
Sanker

Yea, like Rory said.

Private Sub Command1_Click()
Dim rc as Double

rc = Shell("C:\start.exe", vbNormalFocus)
End Sub


Remember to dimension it as a double.
Avatar of aelatik
This way you can open any file, like .txt etc....

Private 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

Private Sub Command1_Click()
Call ShellExecute(hwnd, "Open", ("C:\start.exe"), "", App.Path, 1)
End Sub
Sanker, why dimension as a double -- shell returns an long integer...
Bob,

Shell returns well a double. This number is the task id if the shell command is succefull procced or is zero when not.
kiwitoad:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Moderator, my recommended disposition is:

    Accept RoryR's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer