Groups | Blog | Home
all groups > dotnet interop > january 2006 >

dotnet interop : Running Excel when multiple versions of Excel are installed


Flack
1/31/2006 5:59:09 AM
Hello,

Lets say I built my app on a machine that has Excel 2003 installed. So, the
interop assembly created was built off of 2003.

Now, I have a few questions on what would happen if I ran the following code
on a machine that had, lets say, both Excel 2000 and Excel 2003 installed.

using Microsoft.Office.Interop.Excel;
....
ApplicationClass app = new ApplicationClass();
MessageBox.Show(app.Version);
app.Quit();
....

1. If the user has both Excel 2000 and Excel 2003 installed, which one will
be started? Will it always start the latest version?

2. If no Excel is installed at all, would app be null after the call to new
ApplicationClass() or would that call not even be able to run?

Peter Gummer
1/31/2006 2:21:40 PM
[quoted text, click to view]

It would start whichever version was installed last. If 2000 was
installed last, then it would try to run 2000; or so I've been told.
It's not recommended for users to install older versions when there's
already a newer version installed, however, because apparently it can
leave the Windows registry keys in a mess. Installing newer versions
over older ones is supposed to be ok, though.

So, in practice, because the later version should have been installed
last, that's the one that it will start (i.e. 2003 in your example). If
you find it trying to run 2000, then I think it would be time to
reinstall Excel.

If no Excel is installed at all, then you'd get a "class not
registered" COM exception, I believe.

AddThis Social Bookmark Button