I would like to have a script to:
I can very easily do the first two with the following VB script:
dim accessApp
set accessApp = createObject("Access.Application")
accessApp.visible = true
accessApp.OpenCurrentDataBase("C:\path.accdb")
accessApp.Run "myLinker"
But it immediately closes the Access database when the VBS execution finishes. I would like the instance to remain open independent of the script.
I am not forced to use VBScript for this but it definitely seems the easiest to actually invoke the macro to run.
Create an AutoExec macro If you have already created a macro that contains the actions that you want to occur when the database starts, just rename the macro to AutoExec, and it will run the next time that you open the database.
If you want to leave the application open after the script completes you need to set the UserControl
property to true
.
dim accessApp
set accessApp = createObject("Access.Application")
accessApp.visible = true
accessApp.UserControl = true
accessApp.OpenCurrentDataBase("C:\path.accdb")
accessApp.Run "myLinker"
The Visible
property is technically unnecessary when the UserControl
property is true. It will automatically be set.
More information here: http://msdn.microsoft.com/en-us/library/office/ff836033.aspx
You could also just use a .bat
or .cmd
file and put this because MSACCESS has a command line switch for running a macro and unless that macro closes the database it will remain open for user control.
START "" /MAX "PATH\TO\MSACCESS.EXE" "C:\path.accdb" /x myLinker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With