Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Calling an .exe from vba

Posted on 2004-04-09
4
Medium Priority
?
2,028 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 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 54

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 Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

810 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