Unanswered: Task Schedule created via VBA cannot run properly
I wrote a VBA program to create (and edit) task schedules.
The task is to run a macro inside an MS Access database.
The command line is something like this :
"c:\...\Msaccess.exe" <database name> /wrkgrp <work group file name>
/user username /pwd password /x MACRONAME
My VBA code is listed below for your reference. There should be no problem with the code because it succeeded in creating / editing task schedules.
The problem is scheduled tasks always CRASH.
They don't go beyond the flash screen. It always ends up showing
the error message "Microsoft Office Access has encountered a problem
and needs to close. We are sorry for the inconvenience."
Does anybody know what's the cause of the problem ? Thanks in advance.
Private Sub Command0_Click()
strComputer = "."
Set objService = GetObject("winmgmts:\\" & strComputer)
Set objNewJob = objService.Get("Win32_ScheduledJob")
Are you absolutely 100% sure you're getting the command line value you think you are when executing in VBA?
The error you're getting makes me think the task itself is firing just fine. Clearly Access is getting called, it's just not behaving. If the error isn't erroneous (lolpunlol), then you have some kind of hijinks going on with the ACTUAL command line call. I mean really, how did Access manage to throw an error if it was never called... and how would windows scheduler be responsible for what happens AFTER Access has been called, KWIM?
Edit: Just to clarify, the problem is that the tasks themselves crash when triggered, right?