Solved

Calling an .exe from vba

Posted on 2004-04-09
4
2,012 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
4 Comments
 
LVL 11

Accepted Solution

by:
BillPowell earned 50 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 49

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now