Office & Productivity Software forum

General discussion

Want to run an .exe from Access

I have a tiny c++ program that I would like to run from an Access macro. I cannot seem to get it to work while Access is up. It works by just double clicking the exe. Any suggestions would be greatly appreciated.

Discussion is locked
You are posting a reply to: Want to run an .exe from Access
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: Want to run an .exe from Access
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
Access 2002

In reply to: Want to run an .exe from Access

I forgot to include which version that I am using. Sorry

Collapse -
Re: running an exe from msaccess

In reply to: Access 2002

Use function Shell from Visual Basic. All info you need in VBA-help.


Collapse -
exe problem

In reply to: Re: running an exe from msaccess

yes I tried =shell("c:\(program location)". but it gives me a dos error that it can't find the file it needs which is sitting with it. That is why it runs fine outside of access. Is there another way to do this?

Collapse -
Re: error

In reply to: exe problem

Can you be more explicit on the command (the exact command) and the error message. I've never seen a sitting file, so some explanation on that subject might be useful also. What is "needs" in this case.

And how do you run the program 'outside of access'? From Start>Run, for example.

And how do you start the Access-program?

It might have something to do with the folder the program is running in (as you can set in a shortcut). But, without the error message and details on how you run everything, it's not clear.


Collapse -
explanations, I hope

In reply to: Re: error

Ok, the c++ program basically extracts information from the data folder of another (paradox) program and returns 3 csv files, called user.csv, grades.csv, and class.csv. I don't actually have c++ on my system so I can't really tell you what is actually happening there. But I can simply double click on the exe and the 3 files appear. My access program can import that grades csv and use the data. I works if the grades.csv is there but I can't get it to make the 3 files through shell... only by double clicking the exe.
I know it recognizes or finds the program with shell but it errors out with a dos error from the exe itself, saying it can't find the user.db (which it uses to make the user.csv. and then stops).
I am confused as to why it won't work through Access.
I have the data folder on my desktop along with all the information needed by the exe to create the csv files. I just can't actually run it through a macro.

I have tried a macro with runapp and put in the path
C:\Documents and Settings\Sally.MGMT\Desktop\newest history\DATA\ALSHISTORYDATA.EXE and I Have tried code with =shell("C:\Documents and Settings\Sally.MGMT\Desktop\newest history\DATA\AbSHISTORYDATA.EXE -v"). Both have returned an error "can't find user.db" but it works if you simply double click on abshistorydata.exe

Collapse -
Solution, I hope.

In reply to: explanations, I hope


I always wonder why people should put anything on the desktop other than shortcuts. What's the use of My Documents if you don't use it to put your documents in? But that's not the problem here.

The problem, as I see it, is that the program you run is expecting to find the database in its 'working directory'. And when you run it by doubleclicking in Explorer, that's the folder where the program is located (which happens to be a folder on your desktop C:\Documents and Settings\Sally.MGMT\Desktop\newest history\data). Although you state differently (the file is in the data folder of a paradox program), my guess is that the c++ program expects it in the working directory and doesn't use the full filename; that would be rather unpractical, because one would have to change the program if you moved the paradox database, which is a maintenance nightmare.

Try it by running the program (paste the full name C:\Documents and Settings\Sally.MGMT\Desktop\newest history\DATA\ALSHISTORYDATA.EXE) from the Start>Run box, or from a command window after changing directory to the root folder for example, by typing cd \ (+ enter). I don't know what folder the program will run in from the Start>Run box, but it won't be the above, so you will get the same error.

If you can get the program running in a command window after cd'ing to the right folder (note the use of quotes around long filenames), then it should also run from a shell or runapp in an Access application, provided you use the same working directory then.

Once you've tested what folder to use (the same as your c++ program resides in) put your Access application in that same folder. Then make a shortcut on your desktop to the access application and be sure to have it start in same folder also (that's one of the properties of a shortcut). Then it should work if my idea is correct.

Hope this helps.


Collapse -
so confused

In reply to: Solution, I hope.

Ok, I have moved the whole thing, the Access program, the exe program and the two folders(data and classes) the exe program needs to "my documents". I copied the properties c:\...exe to start run. It works. I open access program paste the same info in runapp and get an error.
Both the exe and the mdb are in the same place under the data folder. I have tried moving the Access one and still get same error.
the path of program is: C:\Documents and Settings\Sally.MGMT\My Documents\newest history\DATA\alshistorydata.exe
the path of access program is C:\Documents and Settings\Sally.CORTEZMGMT\My Documents\newest history\DATA\test history database 05-06.mdb

If you click on the exe it gives 3 files of which I then use a macro to transfer text from one file and use that data. I can't get the 3 files by using runapp or runcode =shell("C:\Documents and Settings\Sally.CORTEZMGMT\My Documents\newest history\DATA\alshistory.exe") But I can if I just click twice or if I do start run and that path.

I didn't get what you meant by using a shortcut. I use one for the particular mdb but I just want a way to click on a button on access and the exe will run.

It seemed easy to me but I am defiantly doing something weird.

Collapse -
Re: run exe from Access

In reply to: so confused

I think you've done what I tried to describe (but didn't to very clearly): move the Access application and the c++ program to the same folder. Then if you can run the c++ program from Explorer by doubleclicking it, you should also be able to run it indirectly by first doubleclicking the Access database and using runapp or shell from coding inside the database. I suppose that is what you do, although it's not 100% clear.

One remarkable thing in your post is that you use two different names for the program: first alshistorydata.exe, then alshistory.exe. Of course, they should be the same. I assume it's a typo.

If you get that c++ program running (as you seem to be doing, because you quote an error message that only can come from inside the program) you maybe better consult the author of the program for advice. Or do you get a different error message now, without telling so.
After all, you will easily be able to show that the shell or runapp command itself are working by running a program like Notepad.exe that way from withing Access. I've never used the commands but I don't real doubts about it. That should prove, more or less, that it's a problem within that c++ program.

There might be a work-around, but it's a rather poor one, maybe. Write a simple batch file that first runs the c++ program and after that opens the Access database. That has the text file then available without you clicking on a button. I don't assume you update the Paradox database from within the Access program (or you could just as well read it directly, of course), and if it doesn't change in the meantime (and why should it) there isn't a real difference.

Good luck, and let us know.


Collapse -
one thought...

In reply to: Solution, I hope.

when Access runs run app or run code for my exe. are the files copied into a temporary folder while this is happening? Just a thought...
The exe doesn't use the access database ever. The access uses the exe's results after it is run. My thought was that access was putting the exe in a temp file while it was handling it or something like that.

Collapse -
Could be, I don't know.

In reply to: one thought...

But I agree it seems to do something unexpected with it.

Did you try the batch file work-around I suggested? . It's a one click solution, but you have to click somewhere else than you use to do. But if the functionality is OK, that doesn't matter so much.

Good luck,


Collapse -
download pwd

In reply to: one thought...

pwd (print working directory) is one of those old (1989) ms-dos utilities (based on a unix command, in fact). You can download it from There might be other versions around (I used to have a program with the same name - never used it, but nice to have - and this one notes it has been downloaded only 2 times) but it will do, I suppose. If it runs on Windows XP, but it might very well do.

It shows the folder it's running in. Simply put it next to your c++ program, change the program name in the runapp or shell command and see what it reports. Then put the input files for that c++ program in that same folder and retry to run it from Access.

Just to try, and success not guaranteed. But I thought it would be an interesting experiment, and about the last thing you can do about it short of changing the program you don't have a source of.


Collapse -
working around with the .lnk

In reply to: download pwd

used a shortcut in same folder, then placed a hyperlink to the shortcut and it works fine. I go get that windows warning about "some files may be harmful...",works fine but anyway to avoid that? I usually use a setwarnings to no but the link is a direct thing.
I have someone looking at the code for c++ and seeing if they can fix the parameter that is messing it up thru runapp.
Thank you for all your assistance.I will try the batch thing. You have been very informative.

Collapse -
(NT) (NT) Good to read you got it working somehow more or less.

In reply to: working around with the .lnk

Collapse -
How to convert an MS Access application to .exe file?

In reply to: explanations, I hope

I would appreciate any help or information about the subject title.
Is there a free("free"/"free for try"), trial or demo version of development tools that convert a .mdb or .mde file to a .exe file?
I'm using Office 2000 PRO with Win/XP Pro, Athlon XP 1.4, 256Mb RD-DRAM, offboard, HD 40 GB, DVD-ROM 16X.
If can someone tell me the solution, please contact me.

Collapse -
Better make this a new question ...

In reply to: How to convert an MS Access application to .exe file?

in stead of burying it into another.

Collapse -
MS Access: Converting .mdb,.mde files to an EXE

In reply to: Better make this a new question ...

Dear Kess:

Thanks for your interest. There is a new question with the same subject title in the "PC applications & utilities" forum.

I'm not sure, but I think there is no way to convert an Access app to an EXE. The Developer's Edition of Office just permit distribute Access apps with a runtime version Of Access for those that don't have Access (using Office 2003). I need better solutions to Access 2000, common to others versions, at the same time.Is it possible? How can I reduce the size of the final file if using the runtime version?

The questions are posted.


Collapse -
Anyway ...

In reply to: How to convert an MS Access application to .exe file?

I don't know of such a tool. But in the Office resource kit you'll find all you need to distribute a runtime version of Access and making an mde-version (kind of an executabe, but not really an exe).
Running Access on a PC without a full development environment is supported by Microsoft this way.

Hope this helps.


Popular Forums

Computer Newbies 10,686 discussions
Computer Help 54,365 discussions
Laptops 21,181 discussions
Networking & Wireless 16,313 discussions
Phones 17,137 discussions
Security 31,287 discussions
TVs & Home Theaters 22,101 discussions
Windows 7 8,164 discussions
Windows 10 2,657 discussions


Sublime suburban chariot

High on style and technology, the 2019 Volvo XC90 is an incredibly satisfying everyday crossover.