Keywords: Excel COM Error, 8008005
As a follow on to my amusing misadventures with Excel COM running server side, I did some more digging and found out more interesting details on this situation. For starters, it’s not supported:KB257757. That doesn’t really bother me so much, it’s stable enough to run a few reports. And I firmly believe that if you’re not getting outside of your safe zone from time to time, then you’re probably not accomplishing very much. (That’s a corollary of Toback’s Law: If you never miss any flights, then you’re spending too much time in airports.)
So anyway, for the past couple of days, I’ve been seeing “Error code 80080005 — server execution failed,” when my report tries to write to an Excel file. The really annoying thing was that I’d try to catch it by resetting the time at which the report would run in the Scheduled Tasks to a few minutes in the future. I’d watch, but the report would invariably run just fine. Since my engineered stakeouts were missing the error, I decided to watch the report run on its own at its normal time. Bingo! Like a broken clock, the report failed at it’s appointed hour.
So what was different? Someone else had started running another daily COM based Excel report at a slightly earlier time under a different user account.
The gist of the Microsoft Knowledge Base article above is that Excel was designed as an interactive program only. The fact that it runs in COM at all is a testament to some technical tradeoffs, and foremost among these seems to be that COM needs to load a user profile to run Excel. Though I’m not an expert on Windows user profiles nor on Windows processes, I’m guessing you can normally have only one user profile per process. Hence COM failed to start Excel for my report because another user profile happened to be loaded at the report time.
I’ve since moved up my report time by five minutes, and it works again.
So to add to my earlier advice for getting Excel COM to work on servers: stagger the reports so that COM doesn’t try to load different user profiles at the same time. If all of your reports are run as the same user, you won’t see this problem. (Oh yes, you’ll see plenty of others…)