We use a lot of VBA automation for client report generation tasks. These processes have been running in some cases for years, and have not changed.
In the last few weeks, there have been intermittent (but still frequent, given the volume of tasks that run through them – multiple times a day) instances of files produced by these processes having 0kb filesize, no content, and the code seemingly just… stopping on that line.
This issue is occurring for multiple teams with similar automation setups, not just in one specific implementation. Occurs in multiple areas of code, with multiple target file types (xlsx, txt). The specific lines of code are as simple as:
Workbooks(strOverlay).SaveAs Filename:=strSaveFolder & strSaveFile, _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
or
For i = 0 To UBound(platformPath)
DoEvents
tempDataBook.SaveAs Filename:=platformPath(i) & dataName, FileFormat:=xlTextWindows
DoEvents
tempIndxBook.SaveAs Filename:=platformPath(i) & indxName, FileFormat:=xlTextWindows
DoEvents
Next i
(the ‘DoEvents’) calls are a recent addition based on a random comment somewhere of someone having a similar sounding problem recently saying it improved things, but no luck for us…)
The second example is relevant, as you can see it is simply 2 save commands back to back, with nothing else in between. From inspection, when it is the first file that is saved as 0kb, there is no second file, indicating it does not move past that line of code at all but exits the function (they are also saved with .creating on the end and then renamed, and this renaming also of course does not happen).
Log files show that it doesn’t seem to pass any specific error back as part of this.
Appreciate there isn’t a huge amount to go on here, but given this is now occurring across multiple processes on multiple machines that have been running without this error for years, and it being intermittent – simply throwing the same file back through will generally see it work 2nd time round – is pretty hard to diagnose beyond ‘has something changed in a recent update?’. No obvious reports of similar issues have appeared in my googling, so turning to StackOverflow to see if anyone is experiencing similar, or has suggestions for how to try to prevent this!
Liam Davis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.