Batch File/VBS to run Macro in open Database

cwell84

New Member
Joined
Oct 10, 2017
Messages
3
I have tried both a batch file and vbs to call a macro to run in a database that is already open. When the database is closed, the macro will run fine with no problems when I execute the batch file. As soon as I try to run it when its open, it fails to execute. I can see the cmd screen window pop open to call the macro, but nothing happens.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Welcome to the Board!

Can you explain exactly what you are trying to accomplish here? If the database is already open, why would you try to be running a macro in it from an outside source instead of just doing from inside the database itself?

If this is a matter of you are trying to schedule something to run at a specific time, and the database may or may not be open at that time, I would approach it in a different manner.
First, split your database into a separate back-end and front-end(s). If you have multiple users (or processes) simultaneously using the same database, this is recommended anyway.
See here for instructions on how to do that: https://support.microsoft.com/en-us...y-split-a-access-database-in-microsoft-access

Then create separate front-ends. One, for your users (and each user should have their own copy of the front-end). And a second for this scheduled process. So the scheduled process would be using its own front-end, and it wouldn't interfere with other users having their own copy of the front-end open.
 
Upvote 0
Welcome to the Board!

Can you explain exactly what you are trying to accomplish here? If the database is already open, why would you try to be running a macro in it from an outside source instead of just doing from inside the database itself?

If this is a matter of you are trying to schedule something to run at a specific time, and the database may or may not be open at that time, I would approach it in a different manner.
First, split your database into a separate back-end and front-end(s). If you have multiple users (or processes) simultaneously using the same database, this is recommended anyway.
See here for instructions on how to do that: https://support.microsoft.com/en-us...y-split-a-access-database-in-microsoft-access

Then create separate front-ends. One, for your users (and each user should have their own copy of the front-end). And a second for this scheduled process. So the scheduled process would be using its own front-end, and it wouldn't interfere with other users having their own copy of the front-end open.


Thanks Joe, what I am trying to do is open a form at specified times with instructions on what is to be accomplished that day. These are machine operators that do not have email. The database is already split into frontend/backend and I am trying to run the macro on each of the frontends. I could possibly open another database, but I think if I do that then it will open in the background behind the already open database and the operators will not see it. Scheduling to run on the backend should not be a problem, however I can't get that to show up on the frontend. I could add a timer to the macro, but everything I have read about timers says that they are buggy and will cause problems.
 
Upvote 0
The issue is that if a user already has the database open, they have exclusive rights to it.
So, I don't know that you are going to be able to run a macro on the database if they already have it open.
I would probably look at putting a different front-end (or different database) on their computer that your Script runs against.
If all it is is a set of instructions, it may not even need to be linked to the back-end of your main database (it sounds like it could be totally separate).

Or, you just may want to look at other means of notifying users (maybe a script that opens a PDF file, or something through Scheduling software, etc).
 
Upvote 0
Thanks again Joe, I thought there was just something I was missing, but the exclusive mode makes sense. The other modes you mentioned, I had already thought of, but in my stubbornness, I was hell bent on making it work.
 
Upvote 0
They don't necessarily have exclusive rights to an entire back end. Did you consider using a hidden timer form in each front end that looks at a BE table for a value (e.g. a checkbox field that you have set to True or whatever) from your Admin function in your FE, and if DLookup in the user's FE finds it to be True, pops up a message form in their FE? Hope you can translate that.
I'd say anything that is user created and is "buggy" is, in most cases, probably a result of poor design.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top