Home » excel » c# – Upgrade to Excel 2007 – app still uses 2003 interop

c# – Upgrade to Excel 2007 – app still uses 2003 interop

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a windows forms application that uses excel to generate some reports.
Untill now it used 2003 but i’ve made an upgrade to use 2007. I have installed on my machine 2003, 2007 and 2010, and my app references Microsoft.office.core, v 12.0 and microsoft.office.interop.excel v 12.0.
But in my code, when i do :

using Excel = Microsoft.Office.Interop.Excel;
......
Excel.Application excelApp = new Excel.Application();
string v = excelApp.Version;

v will be 11.0 .
Also, the path references

C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll

How can this happen?
Any ideea how could i fix it ?

Thank you!

How to&Answers:

You shouldn’t keep both versions (at least on your dev machine).On your clients machine it shouldn’t be a problem . Normally in this situation your code should load the 2007 PIAs. I suggest that you should do a repair . Or do a complete fresh install of 2007.Or fiddle wth the registry and set the active version to 12 (which I don’t recommend)

Answer:

I’ve seen this topic lately, maybe it would be useful for you too: Trying to do Office Automation with Excel 2007, but keeps using Excel 2003.