Completely untested, but you can try GetObject instead of CreateObject, or perhaps the method Daniel shows at the top here:
Paul
------ Original Message ------
From: "ozair" <ozairkhalid@hotmail.com>
Sent: 12/18/2023 9:25:07 AM
Subject: [MSAccessProfessionals] Experiment with Timer & VBS
Hi,This is an experimental task.I wanted to call MS Access file's function from, from a VBS file.It works good but when I again run the VBS, it opens ANOTHER instance of MS Access. (this is undesirable).
It should call the function without opening another MS Access file.
All subsequent calls to the function must be answered from the file already opened.Idea's background;The original idea is to avoid using TIMER inside MS Access file. Instead create a VBS that calls MS Access file's function.That VBS is then added to Windows Task Scheduler. I hope this would help MS Access file remain stable.TIA~ozair'Code in the VBS fileSet accessApp = CreateObject("Access.Application")accessApp.OpenCurrentDataBase "C:\Users\ozair\Desktop\DB1.accdb"accessApp.UserControl = trueaccessApp.Run "HelloMsg"'Function in MS Access file [Module]Public Function HelloMsg()MsgBox "Hello World!", vbExclamationEnd Function
Tidak ada komentar:
Posting Komentar