question from a newbie (a real one)

Posted on 2003-02-19
Medium Priority
Last Modified: 2010-05-01
i want to launch an external executable file (C:\start.exe)

how can i make this happen whith a command button?

Question by:kiwitoad
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

RoryR earned 200 total points
ID: 7980781
id = Shell("C:\start.exe", vbNormalFocus)

put this line of code in the command button eg.

Private Sub Command1_Click()
id = Shell("C:\start.exe", vbNormalFocus)
End Sub

leave id, thats 4 doing more advanced finctions like messing with it when its open :-)

Expert Comment

ID: 7980830
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.
LVL 14

Expert Comment

ID: 7980859
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 7981347
Sanker, why dimension as a double -- shell returns an long integer...

Expert Comment

ID: 7981688

Shell returns well a double. This number is the task id if the shell command is succefull procced or is zero when not.

Expert Comment

ID: 8901468
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?
LVL 49

Expert Comment

ID: 8959624
Moderator, my recommended disposition is:

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

DanRollins -- EE database cleanup volunteer

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question