Solved

Calling an .exe from vba

Posted on 2004-04-09
4
2,019 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 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 52

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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.
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 …

689 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