For many reasons, I installed MSExcel 2003 and MSExcel 2007 on my laptop. I need both versions to develop specific projects for each version (document-level projects and application-level projects). Now I need to make a WinForm project that opens an Excel file, read CustomXMLParts and write a new Excel file. I use a link to Microsoft.Office.Interop.Excel, which use .. \ Visual Studio Tools for Office \ PIA \ Office12 \ Microsoft.Office.Interop.Excel.dll library (this is for Excel 2007). And for this code:
Microsoft.Office.Interop.Excel.Application excelApplication; excelApplication = new Microsoft.Office.Interop.Excel.ApplicationClass(); string version = excelApplication.Version;
At this point, the version is "11.0", but I need to open Excel 2007, and it should be "12.0", and then when the program tries to get CustomXMLParts, it throws an exception because this method does not exist in 2003.
If I uninstall Excell 2003, it works fine, but I need to work with both (2003 and 2007). When I reinstall Excell 2003, it again fails. I check the “Specific Version” property for the Interop.Excel link to make sure it is true, and I tried changing app.config oldVersion = "12.0.0.0" so that it was not compatible with Excel 2003, but nothing happens:
<assemblyIdentity name="Microsoft.Office.Interop.Excel" publicKeyToken="71E9BCE111E9429C" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="12.0.0.0"/>
Any idea?
I am using Visual Studio 2008 and Visual Studio Tools for Office. Thanks in advance.
source share