Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling an .exe from vba

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 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