question

OlleAxelsson-1462 avatar image
0 Votes"
OlleAxelsson-1462 asked OlleAxelsson-1462 commented

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

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

office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered OlleAxelsson-1462 commented

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).

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for good and fast response!
I have limited the loop and added a delay.

Thanks again and have a great day!
Best Regards
Olle

0 Votes 0 ·