B
Brad Baker
I'm trying to schedule a VB script to run via task manager. The script
should kick off an access macro and then close down when done. However I am
getting the two following error messages when I try to run the script:
-------------------------
(i) You can't exit Microsoft Office Access now.
If you're running a Visual Basic module that is using OLE or DDE, you may
need to interupt the module.
-------------------------
-------------------------
(i) The RunMacro action was canceled.
You used a method of the DoCmd object to carry out an action in Visual Basic
but then clicked Cancel in a dialog box.
For example, you used the Close method to close a changed form, then clicked
Cancel in the dialog box that asks if you want to save the changes you made
to the form.
[OK]
-------------------------
Below is my VB script. Maybe I'm coding something wrong? Could anyone
provide any suggestions?
Thanks
Brad
Dim DBName, MacroName
DBName = WScript.Arguments(0)
MacroName = WScript.Arguments(1)
On Error Resume Next
Dim AcApp
Set AcApp = CreateObject("Access.Application")
If Val(AcApp.Version) >= 11 Then
AcApp.AutomationSecurity = 1 ' msoAutomationSecurityLow
End If
AcApp.Visible = True
AcApp.OpenCurrentDatabase DBName
If AcApp.CurrentProject.FullName <> "" Then
AcApp.UserControl = True
Else
AcApp.Quit
MsgBox "Failed to open '" & DBName & "'."
End If
AcApp.DoCmd.RunMacro MacroName
acApp.CloseCurrentDatabase
AcApp.Close
AcApp.Quit
Set appAcc = Nothing
should kick off an access macro and then close down when done. However I am
getting the two following error messages when I try to run the script:
-------------------------
(i) You can't exit Microsoft Office Access now.
If you're running a Visual Basic module that is using OLE or DDE, you may
need to interupt the module.
-------------------------
-------------------------
(i) The RunMacro action was canceled.
You used a method of the DoCmd object to carry out an action in Visual Basic
but then clicked Cancel in a dialog box.
For example, you used the Close method to close a changed form, then clicked
Cancel in the dialog box that asks if you want to save the changes you made
to the form.
[OK]
-------------------------
Below is my VB script. Maybe I'm coding something wrong? Could anyone
provide any suggestions?
Thanks
Brad
Dim DBName, MacroName
DBName = WScript.Arguments(0)
MacroName = WScript.Arguments(1)
On Error Resume Next
Dim AcApp
Set AcApp = CreateObject("Access.Application")
If Val(AcApp.Version) >= 11 Then
AcApp.AutomationSecurity = 1 ' msoAutomationSecurityLow
End If
AcApp.Visible = True
AcApp.OpenCurrentDatabase DBName
If AcApp.CurrentProject.FullName <> "" Then
AcApp.UserControl = True
Else
AcApp.Quit
MsgBox "Failed to open '" & DBName & "'."
End If
AcApp.DoCmd.RunMacro MacroName
acApp.CloseCurrentDatabase
AcApp.Close
AcApp.Quit
Set appAcc = Nothing