1

Possible Duplicate:
C#: How to know whether certain Office 2003 or 2007 application is installed?

How can I check if Microsoft Office is installed using C#?

Community
  • 1
  • 1

3 Answers3

8

If you don't need a specific Office version present, you can check by looking up the App Path to one of the office apps (winword.exe for instance):

private static bool IsOfficeInstalled()
{
    RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe");
    if (key!= null)
    {
        key.Close();
    }
    return key != null;
}
Fredrik Mörk
  • 155,851
  • 29
  • 291
  • 343
  • Is the above Registry path reliable? See [here](http://stackoverflow.com/questions/3266675/how-to-detect-installed-version-of-ms-office/3267832#3267832). – Masood Khaari Oct 30 '13 at 07:16
  • @MassoodKhaari I don't know how reliable it is, but it's still valid on both systems I have access to right now (Win7/Office2010 and Win8.1/Office2013). – Fredrik Mörk Oct 30 '13 at 13:32
  • 1
    OK. It **probably** always works. But it's nicer to use the officially stated Registry key mentioned in that link. – Masood Khaari Oct 30 '13 at 13:47
0

You could root around in the registry:-

HKEY_LOCAL_MACHINE\Software\Microsoft\Office\nn.n\Word\InstallRoot

The nn.n will be the version installed 11.0 or 12.00

James Anderson
  • 27,109
  • 7
  • 50
  • 78
0

try to create the object with the version in it and if it throws out error, it is evident that the MSOffice you are looking for is not installed.

Try some thing like the below

try
{
    //try creating the object here.

}
catch(Exception ex)
{
  // You can decide that the 3rd party instance required is not installed

}

Because all the clients would not give you the permission to read the registry