Quantcast
Channel: Andrew den Hertog » C#Andrew den Hertog
Viewing all articles
Browse latest Browse all 10

C# Excel Interop With Multiple Versions (2000, 2003, 2007)

$
0
0

At times when you’re using Excel interop automation with C#, you’ll run into environments that have multiple version of the application installed. Occasionally the most recent or highest version installed won’t be the default that can cause issues especially when you have eg v14 of the office.dll that’s mostly incompatible with Excel 2000 and below.

The easiest way to fix this is via the registry. Even if Excel 2007 etc is the default version that launches when you call excel.exe, it doesn’t mean that this is the default for COM invoked calls. COM launches the app based on its CLSID, which for excel is {00024500-0000-0000-C000-000000000046}. This will resolve to one or more keys depending on how many versions of Excel are installed (eg: Excel.Appplication.9, xcel.Appplication.12 etc).

Basically if you want to set Excel 2007 to be the COM default, you’ll need to update this for the CLSID. To do this:

  • Open your registry (regedit.exe)
  • Navigate to HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}
  • Select the “LocalServer” folder, and update (Default) to your Excel 12 folder
  • Delete the data for the “LocalServer” key
  • Do the same for “LocalServer32″

These changes are instant so you don’t need to restart your PC. Just run your interop app again and you’ll see that COM invokes Excel 2007.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles



Latest Images