Link to home
Start Free TrialLog in
Avatar of JP_TechGroup
JP_TechGroupFlag for United States of America

asked on

Use batch file to run a macro on OPEN Access database

Is there a way to use a batch file or script to run a macro, function or sub on an Access database that is already open? I know I can do this on a closed db as below:

START "" "C:\Program Files\Microsoft Office\Office12\MSACCESS.exe" "H:\Cor-Pro\Woksu\Update\working file\WokSu V 1.5.accdb" /x mcrBatch /cmd 470

Open in new window

For example..

Thanks.
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Can you put some context on this.  There is no obvious reason why you would not just do what you want from a an open copy of the application.  Why do you need something external to trigger the process.
Avatar of JP_TechGroup

ASKER

The program sends emails with references to records in the database.
We want to add the ability for users to click on a hyperlink in the body of the email that will open the specified record.
Since Outlook does not support command line switches that use a forward slash, we are getting around it by creating batch files that have the commands needed and hyperlinking to them.
No, It isn't really elegant, but it will work... provided we can call an event, macro, sub or function externally on an already opened database. Make sense?
I think it is not possible directly as you like. You need some data exchange between programs. In Access you can use timer event for collecting some data (external file, clipboard, some table data etc.). From Outlook fill this intermediate object with nesessary data.
Yea, I didn't really want to run this as a timer event. Too many people accessing this resource from a terminal server concurrently. We'll run out of resources very quickly that way, me thinks.

So am I correct in thinking this can't be done then?
You can do it manually. Set flag in Outlook, then click on form and get result.
Sorry, you just took too many shortcuts for a humble developer. Please explain a bit more about what you mean!
I have no experience with Outlook events, but I hope you can do it. I think from Outlook VBA best way - to write records to your DB (if you like bat - use vbscript or powershell). Add table with:
userID (or may be user name), record id (or any other parameter, which can help you to find record), flag (boolean, you should set it to true from Access when record will be opened).
On Access form create button ("Check events", for example), and in code check records in your table with correct userid and flag = false and open these records.
ASKER CERTIFIED SOLUTION
Avatar of JP_TechGroup
JP_TechGroup
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is no solution.