I use the following code to open excel, run a macro and then close excel from an access database. Unfortunately, I get the following error when I try re-runing the code (from a loop statement):
Method 'Run' of object '_Application' failed!
It seems that the second time through it isn't opening the "Protocols-Cleanup.xls" file and therefore can't run the "GetFromAccess" macro. Any suggestions????
Code used by Access
**************************************************
Dim ObjExcel As Excel.Application
Set ObjExcel = New Excel.Application
ObjExcel.Visible = True
AppActivate "Microsoft Excel"
Workbooks.Open (strPath & "\Protocols-Cleanup.xls")
'The "strPath" statement passes the database location from the MainMenu
'Further, this "Run" statement moved the "Run Protocols_Filters",
'"Run Builtin_Filters", and "Run Filters_Filters" to the excel form
ObjExcel.Run "GetFromAccess", strPath
Workbooks.Close
ObjExcel.Quit
ObjExcel.Application.Quit
Set ObjExcel = Nothing
Method 'Run' of object '_Application' failed!
It seems that the second time through it isn't opening the "Protocols-Cleanup.xls" file and therefore can't run the "GetFromAccess" macro. Any suggestions????
Code used by Access
**************************************************
Dim ObjExcel As Excel.Application
Set ObjExcel = New Excel.Application
ObjExcel.Visible = True
AppActivate "Microsoft Excel"
Workbooks.Open (strPath & "\Protocols-Cleanup.xls")
'The "strPath" statement passes the database location from the MainMenu
'Further, this "Run" statement moved the "Run Protocols_Filters",
'"Run Builtin_Filters", and "Run Filters_Filters" to the excel form
ObjExcel.Run "GetFromAccess", strPath
Workbooks.Close
ObjExcel.Quit
ObjExcel.Application.Quit
Set ObjExcel = Nothing
Last edited: