How to Check Whether Word is Installed in the System or Not






4.94/5 (15 votes)
After the tip on Excel, here we will explore the trick to verify whether Word is installed in the client's system or not by C#.
Introduction
After the tip on How to Check Whether Excel is Installed in the System or Not, we are going to do the same for Microsoft Word.
If you are using Microsoft.Office.Interop.Word
for Word related operations in your application, then you must check if Word is installed in the client machine or not. This tip gives you that trick.
Background
This little piece of code is a result of the research after the comment by Marco Bertschi on my previous tip (How to Check Whether Excel is Installed in the System or Not). Thanks a lot Marco. :)
Marco Bertschi saysNice one, Tadit - It might be even improvable by providing information what the ProgID for the other office applications are (Word etc., but maybe even Visio or MS Project).
Using the Code
We will use Type Class
and its method Type.GetTypeFromProgID Method (String)
.
Gets the type associated with the specified program identifier (ProgID
), returningnull
if an error is encountered while loading the Type.Return Value
Type: System.Type
The type associated with the specified
ProgID
, ifprogID
is a valid entry in the registry and a type is associated with it; otherwise,null
.
For Word, the ProgID
is Word.Application
. So, the below code is used to check whether Word is installed or not.
Type officeType = Type.GetTypeFromProgID("Word.Application");
if (officeType == null)
{
// Word is not installed.
// Show message or alert that Word is not installed.
}
else
{
// Word is installed.
// Continue your work.
}
History
- 29 November 2013 - First version submitted