I am trying to use the following code to update seven Excel workbooks. At
this point (second file to refresh) I get Runtime error 1004 SaveAs method of workbook class failed.
I continue the code with F5 and the next error is Runtime error 1004 Cannot access "fourth file" again the code continues to run with F5.
I have run this numerous times and am not getting the errors for the same files each time. Just a combination of 1004 with Can't Access file or SaveAs method failed.
When I check the files, they show last updated at the correct time but the data may or may not have actually refreshed. Any help achieving consistent refreshed results would be appreciated.
Using Access 2010, W7
this point (second file to refresh) I get Runtime error 1004 SaveAs method of workbook class failed.
Code:
xlWb.SaveAs ("P:\FileLocation\Speciality All Regions Forecast Template.xlsx")
I continue the code with F5 and the next error is Runtime error 1004 Cannot access "fourth file" again the code continues to run with F5.
I have run this numerous times and am not getting the errors for the same files each time. Just a combination of 1004 with Can't Access file or SaveAs method failed.
When I check the files, they show last updated at the correct time but the data may or may not have actually refreshed. Any help achieving consistent refreshed results would be appreciated.
Using Access 2010, W7
Code:
Dim xlApp As Object
Dim xlWb As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
Set xlWb = xlApp.Workbooks.Add("P:\FileLocation\Cariflex Forecast Template.xlsx")
xlWb.RefreshAll
xlWb.RefreshAll
xlWb.SaveAs ("P:\FileLocation\Cariflex Forecast Template.xlsx")
xlWb.Close SaveChanges:=True
Set xlWb = Nothing
xlApp.Quit
Set xlApp = Nothing
Last edited: