Hello,

I'm not sure that I have a solution to your problem, but it sounds as if the connection between Excel and your servers has broken somewhere in the process (which is why Excel cannot save directly to the server, or delete an object from the server). I have come across this issue many times over the years, and whilst frustrating I'm not sure there is much you can do about it. The fact that the error occurs 'randomly' means it will be difficult to point the finger at the code as in some passes a file may work fine, and in others it may stop. I suspect then that it is nothing to do with your code or the actual files themselves, but more likely to be caused by an unreliable server connection (even a split second flicker can cause Excel to break).

There maybe some clever API calls that can re-establish the connection that may get around this, but I have never heard of anything.

I think one solution that may 'help' would be to maintain a text file log of the files that you have converted successfully as the code runs, so that the next time it breaks you can resume the routine where it left off, rather than having to re-save every workbook each time. Alternatively, you could just check to see whether a file of 'xlsm' type already exists, and skip over the file if this is the case?

Not very helpful I'm afraid, but hopefully a couple of pointers for you here.

Kind regards,
Simon