?
Solved

Calling an .exe from vba

Posted on 2004-04-09
4
Medium Priority
?
2,023 Views
Last Modified: 2008-03-06
Hi all,

I've created an .exe file from vb6. Now i need to open it from access.
I keep reading about people using SHELL to open the .exe, any simpler ways to do so?

Xhenkaii
0
Comment
Question by:xhenkaii
[X]
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
4 Comments
 
LVL 11

Accepted Solution

by:
BillPowell earned 150 total points
ID: 10795775
Simplest way is to create a command button while the wizards are turned on (the magic wand in the tool box toolbar).  Once you create the button you will be prompted for an action.  Choose Application and Run Application.  The next step will prompt you for a command line.  Here you can enter the program you wish to open.

Another way is to use the FollowHyperlink method:

FollowHyperlink "C:\Program Files\MyApp.exe"

You will need to put this in the code behind the click event of a command button or however else you wish to open it.

Hope this helps,

Bill
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10795820
If you want to know how to use Shell

its basically this

Shell("path of exe","window size")

where path of exe is full pathame e.g C:\MyDir\MyExe.exe
where windowsize can be one of

vbHide
vbNormalFocus
vbMinimizedFocus
vbMaximizedFocus
vbNormalNoFocus
vbMinimizedNoFocus


bit Bill's is the simplest 'cos no coding required

also RunApp will produce code that uses Shell anyway, this post was just to inform you of the syntax of Shell

0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 10796856
or try use the ShellExecute API:

In a module:

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

Public Function StartDoc(ByVal FileName As String, Optional CommandLine As String = "") As Long
    StartDoc = ShellExecute(0&, "Open", FileName, CommandLine, vbNullString, 1)
End Function

then try like:

StartDoc "c:\myexe.exe"

cheers
0
 

Author Comment

by:xhenkaii
ID: 10803363
ahhh sheesh. stupid me not to realise i can do it with the magic wand. Thanks bill for providing that information.

Thanks to rock and ryan for sharing about SHELL too. I've tried your code and it works good.
Cheers!
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

741 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