Thanks in advance for any guidance! I have a VBA macro in an Excel sheet that gives the following error when it loops after a few times, which has me stumped:
Run-time error '-2147417848 (80010108)': Automation error. The object invoked has disconnected from its clients.
The application flow works like this:
- For next country in array
-- Clear the spreadsheet
-- Load data from database into spreadsheet
-- Do lots of processing on data
-- Do a save as on this current file (to create country-specific versions)
- Next
This iterator works fine for every country in the loop individually, and even for 2 or 3 in a sequence. But invariably, it crashes with that error (after which I must force quit Excel to exit) after the 5th iteration. My internet research on the error has described problems caused by early binding when Excel is opened from a VB script calling it from outside, but since my entire codebase is contained within 4 modules in a single Excel workbook, that seems not to be relevant to my problem.
I have verified that all the database connections are closed after I use the recordset, and there are no file objects referenced except the save as command, ActiveWorkbook.SaveAs filename:=fileRoot. And all the modules have Option Explicit at the top.
Thank you!
Bookmarks