Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check excel version at install

Status
Not open for further replies.

ralphtrent

Programmer
Jun 2, 2003
958
0
0
US
Hello
I need to check the version of excel during an install. I have a console app that will look for a reg key. I added this to an install CustomAction, but not sure what to do from there. I tried googleing for help but that got me more confused.

Also, I am using the Excel object from 2007. Should that work on users running office 2003?

Thanks,
RalphTrent
 
As to your second question, the answer is probably no. You will need to include a reference to whatever version of Excel your users have installed.

In Solution Explorer, you need to right click, then choose 'Add Reference'. Under COM, choose MS Excel version you need. Take a look here for an excample of using Excel 2003 in a C# app:
 
So you're trying to find out which Excel version is installed on the user's computer?

This would do that:

Code:
public string Read(string KeyName)
{
    RegistryKey baseKey = Registry.ClassesRoot;

    RegistryKey subKey = baseKey.OpenSubKey(@"Excel.Application\CurVer");

    if (subKey == null)
    {
        return null;
    }
    else
    {
        try
        {
            return (string)subKey.GetValue(KeyName.ToUpper());
        }
        catch
        {
            return string.Empty;
        }
    }
}

And you'd use it like this:
Code:
string s = Read(string.Empty);

You have to put string.Empty, because you're checking a (Default) key.


If you have 2007, you get Excel.Application.12

I'm sure you can match other results if you Google a bit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top