我在Windows中使用任务调度程序来触发宏,我想用Access数据库accdb文件格式执行此操作,但是我一直在收到错误
对象需要opencurrentdatabase(“”)
'Run Database
Dim ObjAccess, ObjDB
Set ObjAccess = CreateObject("Access.application")
objAccess.visible = false
Set ObjDB = ObjAccess.OpenCurrentDatabase("filepath\filename.accdb", False) 'error occurs here
ObjDB.Application.Run "'Checklist.accdb'!cmdChkSelectAll_Click"
ObjDB.Application.Run "'Checklist.accdb'!cmdGenerateAllLists_Click"
ObjDB.Close False
ObjAccess.Quit
Set ObjAccess = Nothing
答案 0 :(得分:0)
以下内容适用于在常规模块和宏中运行VBA过程:
Dim ObjAccess
Set ObjAccess = CreateObject("Access.application")
ObjAccess.visible = false
ObjAccess.OpenCurrentDatabase("filepath\filename.accdb")
ObjAccess.Run "Test6"
ObjAccess.DoCmd.RunMacro "Macro1"
ObjAccess.Quit
Set ObjAccess = Nothing