次の方法で共有


How to solve “Unable to cast COM object of type Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'”

Recently I was working on a problem where a customer received that error message when trying to open a TFS work item list in Excel triggered from Team Explorer.

The error did not appear when opening Excel right away and accessing a TFS query.

I was checking Process Monitor to see what was going on underneath using the comparison technique that I learned from Mark Russinovich.

It turned out that Excel 2007 was installed and it’s COM Classes are registered in HKCR\TypeLib\{00020813-0000-0000-C000-000000000046}\1.6.

In contrast when Team Explorer wanted call Excel through COM automation it used HKCR\TypeLib\{00020813-0000-0000-C000-000000000046}\1.7.

Obviously TFS was trying to talk to Excel 2010 instead which was not present.

So I rang the customer to discuss it further and it turned out that they installed Project 2010 to these boxes running Office 2007 that seemed to have added a newer automation class registry key for Excel though even though it was not even installed.

Anyway, deleting the key HKCR\TypeLib\{00020813-0000-0000-C000-000000000046}\1.7 solved the issue for the customer.

Project, Excel and Team Explorer work fine with that tiny little change.

My learnings: “When in doubt, run process monitor.” Smiley

Comments

  • Anonymous
    May 10, 2012
    Thanks that helped. Had to do the same and it worked like a charm.

  • Anonymous
    May 29, 2012
    Awesome - solved my problem that I have been battling for hours - thanks!!!

  • Anonymous
    August 26, 2012
    Really worked out for me also...solved the issuse...thanks

  • Anonymous
    January 11, 2013
    Thanks. Helped me a lot

  • Anonymous
    January 30, 2013
    Thanks man, solved my problem too after hours of digging, Thanks a lot