Error code 1004 during saving : cannot access file/folder 6DED7E10

Olle Axelsson 21 Reputation points
2021-03-18T08:19:52.433+00:00

Hi! I have created a power shell script that opens three instances/threads of excel. One of the threads are responsible for the other two threads and communicates with them via a text file. Here is a sample of how each excel application is created: Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open("XX.xlsm") objExcel.Application.DisplayAlerts = True objExcel.Application.Visible = False objExcel.Application.Run ExampleFcn objExcel.ActiveWorkbook.Close objExcel.Application.Quit objExcel.Quit Set objWorkbook = Nothing Set objExcel = Nothing WScript.Quit Every new day the master thread creates a new folder and write to the text file that its time to save current workbook and create a copy (in the new folder) and continue in the new folder. These commands are used: ThisWorkbook.Save ThisWorkbook.SaveCopyAs nameFullFilePath But almost every day I get an error msg: - error code: 1004 Microsoft excel cannot access the file .\pathToWorkbook\6DED7E10 I have implemented a for loop with "on error resume next", to try several times, and it works the next time it attempts to save. So my question is: what is the 6DED7E10 file/folder? Has it something to do with the WScript, or something to do with the new created folder, maybe it takes too long time to create the folder and the other threads are too quick? Any ideas? Best Regards Olle

0 comments No comments
{count} votes

Accepted answer
  1. Viorel 114.4K Reputation points
    2021-03-18T09:54:51.64+00:00

    Occasionally, but not often, some similar problems are reported, related to file system, in various languages. For example, sometimes it is not possible to delete a file and create immediately a new homonymous one. Although, the operation succeeds after a short delay or several reiterations.

    Maybe in your case the Save and SaveCopyAs operations create the temporary file called 6DED7E10 and you observe the similar system limitation. I think that you have found the right approach using a loop. Maybe you can also add a small delay after failures. Probably it is also good to distinguish the errors (to not repeat the loop in case of certain critical hardware errors, for example) or maybe to limit the time of such loops (to avoid infinite loops if the operation does not seem retriable).


0 additional answers

Sort by: Most helpful