Reputation: 187
I have a .vbs script that copies a master MS Access application that I distribute to my users called AccessApp.accde
. The file is located at a specific location on my network. When I run this .vbs script, AccessApp.accde
is copied from the network location to the specific local location with the same name, overwriting the file if it already exists.
This works great!
My only hurdle is closing the file at my user's local location if it's already open. This is important because my app performs a version check internally and runs this external script if the user's version is out-of-date. The script should close the file before copying down the new file over it, and open it again. Seems like it should be really simple, but I can't figure out the proper VB syntax used to check if a file (specifically an .accde) is open, and close it if it is.
Does this make sense? Am I missing something really simple here?
Upvotes: 1
Views: 836
Reputation: 97101
Since AccessApp.accde
includes a procedure which shells out to a VBScript which then replaces AccessApp.accde
, tell Access to shut itself down immediately after calling the VBScript :
Application.Quit ' optionally followed by acQuitSaveAll or acQuitSaveNone
You can modify the VBScript to wait a bit in order to give Access time to complete its shutdown before copying over the new ACCDE:
WScript.Sleep 2000 ' units are milliseconds, so this is 2 seconds
Upvotes: 1