The system that is failing is an enterprise license to the company the version is 2408 and the Build is 17928.20156.
There are 5 spreadsheets involved, but so far only two of them are exhibiting the issue. Unfortunately, there is too much proprietary data involved to sanitize the files for public publishing. Also, the problem is very intermittent and random. I've not been able to reproduce the errors. Howeve,r I will describe them.
The user logs into a 3rd party application, runs a report and downloads the data to a CSV or XLS(!) file. I use Power Query to read the data into tables in the application. We have two dozen departments. The application looks at each of them and summarizes the information into a Table for a display and also creates a file with information specific to that department. The Table is included in the body of the email and the table is attached and the mail is sent off. In addition, information is summarized and written to a historical table. This process occurs for each department.
The program fails at random departments and at random places in the code.
I suspect the failures are happening when creating the files to be attached for the emails. These are stored with the department names and a date stamp in an archive directory on the server. So the creation and building of these files occurs over the internet. Also, the transactions that write to the historical file also go over the internet.
The most common point of failure is in the paste function:
SomeRange.Copy
OtherRange.PasteSpecial xlPasteValues
OtherRange.PasteSpecial xlPasteFormats
The failure occurs on the second paste special.
I have put in a number of DoEvents into the code where I thought it was critical.
I can rewrite the program to download the data over the internet (There's not much I can do about that.), process it on the C:Drive and then after all the mail has gone out, move all the files across the internet to the server.