Reputation: 35557
I use a virtual pc to run my macros.
Currently when I remote into this pc I find Excel open with a run-time error 1004 describing File "Daily_Summary.xlsx" cannot be found
and when I open the VBA
editor it has the following line highlighted:
Excel.ActiveWorkbook.SaveAs "C:\PDFfiles\Daily_Summary.xlsx"
At this point Daily_Summary.xlsx
does not exist, until it has been saved so I wouldn't expect the program to be able to find the file - therefore the error message seems strange.
Initially I thought maybe it would be network issues due to it being a virtual pc but the line of code is trying to save the file locally to the c-drive
so how can it be a network issue?
Anybody ever experienced anything like this before?
Upvotes: 1
Views: 19519
Reputation:
Your code should work fine in case of referring to a file different than the current one (from which the macro is executed). You would get a (1004) error message only if this file is not accessible for some reason.
On the other hand, if you are intending to save the current file (from which the macro is being executed), an error would be triggered every time because of intending to save it as a XLSX file. A file containing macros has to be stored as a macro-supporting format (e.g., XLSM). If you try to save it by relying on a wrong file type (like XLSX), you would get a prompt explaining the problem. But, if Application.DisplayAlerts = False
is present in your code, you would get the standard 1004 error message when the file cannot be accessed (as in the example above).
Upvotes: 1