Sauron
Sauron

Reputation: 16903

Check MSWord is Installed in system

Exact Duplicate:

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

How to check if MSWord 2003 0r 2007 is installed in the system using C# code?

Upvotes: 6

Views: 6843

Answers (2)

Noldorin
Noldorin

Reputation: 147260

This code shows that a simple registry check will do the job.

Here is the code converted to C# (and slightly improved to use a using statement).

using Microsoft.Win32;

// Check whether Microsoft Word is installed on this computer,
// by searching the HKEY_CLASSES_ROOT\Word.Application key.
using (var regWord = Registry.ClassesRoot.OpenSubKey("Word.Application"))
{
    if (regWord == null)
    {
        Console.WriteLine("Microsoft Word is not installed");
    }
    else
    {
        Console.WriteLine("Microsoft Word is installed");
    }
}

Note that it's not good enough to check C:\Program Files\Microsoft Office\ for the msword EXE file, as the user might have installed it somewhere else.

Upvotes: 13

Cshah
Cshah

Reputation: 5840

One of the solution, i reckon there should be better if you google it. To Check whether Excel is installed or not, I use this c# code

Excel.Application app = new Excel.ApplicationClass();

if app == null that means excel is not installed on the machine.If you check the MSDN docs, you should be able to get the syntax for opening a word appln.

Upvotes: 0

Related Questions