So I am looking to open an access database on a daily basis using task scheduler. I want this script to open the .aacdb and then open a specific form. The problem is, this database has an auto executable that opens a different form that will close the program when exiting out of it. I need to somehow bypass this executable. I've been trying to write a .vbs script that will use the hold down shift key (to bypass the auto executable) > open database > release shift key > open form > close database. After days of searching, I can't seem to find any answers on whether this is possible. Here is what I have so far (it opens the database but doesn't bypass the auto executable). The aim of this script is to hold down the shift key for 10 seconds while opening the database.
b = DateAdd("s", 10, Time)
Set WshShell = CreateObject("WScript.Shell")
Set appAccess = CreateObject("Access.Application")
appAccess.Visible = True
strDBNameAndPath = "C:\FileFolder\file.aacdb"
Do While (Time < b)
WshShell.SendKeys "+"
Loop
appAccess.OpenCurrentDatabase strDBNameAndPath
Set WshShell = Nothing
I can't mess with the actual database (the macros), this has to happen by somehow bypassing the actual auto executable upon opening a database. Is this possible in .vbs? .vba? .vb? vb.net? any language?? I'm only familiar with .vbs. But any insight would be helpful. Thanks!!!
SendKeys
doesn't work that way. It doesn't support holding down keys and releasing them. The WinAPISendMessage
function does support sending KeyDown and KeyUp statments separately, you can use that in either VBA or VB.Net, but not in VBScript afaik.