Click here to Skip to main content
15,868,340 members
Articles / Productivity Apps and Services / Microsoft Office / Microsoft Excel
Tip/Trick

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

7 Nov 2013CPOL 61.2K   10   19
Here we will explore the trick to verify whether Excel is installed in the client's system or not by C#.

Introduction

If you are using <a title="Microsoft.Office.Interop.Excel Namespace" href="http://msdn.microsoft.com/en-us/library/ms262200(v=office.11).aspx">Microsoft.Office.Interop.Excel</a> for Excel related operations in your application, then you must check if Excel 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 during development of one Windows Utility, which uploads Excel sheets to database.

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), returning null if an error is encountered while loading the Type.

Return Value

Type: System.Type
The type associated with the specified ProgID, if progID is a valid entry in the registry and a type is associated with it; otherwise, null.

For Excel, the ProgID is Excel.Application. So, the below code is used to check whether Excel is installed or not.

C#
Type officeType = Type.GetTypeFromProgID("Excel.Application");

if (officeType == null)
{
    // Excel is not installed.
    // Show message or alert that Excel is not installed.
}
else
{
    // Excel is installed.
    // Continue your work.
}

History

  • 07 November 2013 - First version submitted for approval

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Proud Indian | Author | TEDx Speaker | Microsoft MVP | CodeProject MVP | Speaker | DZone Most Valuable Blogger| jsfiddler

My Website

taditdash.com

Programming Community Profiles

jsfiddle | Stack Overflow

Social Profiles

Facebook | Twitter | LinkedIn

Awards


  1. DZone Most Valuable Blogger
  2. Microsoft MVP 2014, 2015, 2016, 2017, 2018
  3. Code Project MVP 2014, 2015, 2016
  4. Star Achiever of the Month December 2013
  5. Mindfire Techno Idea Contest 2013 Winner
  6. Star of the Month July 2013

Comments and Discussions

 
QuestionDoes this code fails if Excel not installed in machine ? Pin
kiquenet.com25-Mar-15 2:08
professionalkiquenet.com25-Mar-15 2:08 
AnswerRe: Does this code fails if Excel not installed in machine ? Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)25-Mar-15 3:31
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)25-Mar-15 3:31 
GeneralRe: Does this code fails if Excel not installed in machine ? Pin
kiquenet.com25-Mar-15 4:22
professionalkiquenet.com25-Mar-15 4:22 
AnswerRe: Does this code fails if Excel not installed in machine ? Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)25-Mar-15 4:37
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)25-Mar-15 4:37 
GeneralRe: Does this code fails if Excel not installed in machine ? Pin
kiquenet.com25-Mar-15 5:29
professionalkiquenet.com25-Mar-15 5:29 
GeneralMy vote of 5 Pin
Sibeesh KV13-Nov-14 17:56
professionalSibeesh KV13-Nov-14 17:56 
GeneralRe: My vote of 5 Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)17-Nov-14 2:50
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)17-Nov-14 2:50 
GeneralRe: My vote of 5 Pin
Sibeesh KV17-Nov-14 4:23
professionalSibeesh KV17-Nov-14 4:23 
QuestionCheck if Excell installed is 64 bit or 32 Bit Pin
thangtx17-Mar-14 1:24
thangtx17-Mar-14 1:24 
AnswerRe: Check if Excell installed is 64 bit or 32 Bit Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)20-Mar-14 19:18
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)20-Mar-14 19:18 
QuestionWhich Excel version(s) is installed? Pin
Dennis M Wallentin11-Nov-13 2:49
Dennis M Wallentin11-Nov-13 2:49 
AnswerRe: Which Excel version(s) is installed? Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)11-Nov-13 3:41
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)11-Nov-13 3:41 
AnswerRe: Which Excel version(s) is installed? Pin
MadJohn11-Nov-13 17:47
MadJohn11-Nov-13 17:47 
AnswerRe: Which Excel version(s) is installed? Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)11-Nov-13 19:02
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)11-Nov-13 19:02 
GeneralMy Vote of 4 Pin
Patil Kishor7-Nov-13 12:58
Patil Kishor7-Nov-13 12:58 
good work done
GeneralRe: My Vote of 4 Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)7-Nov-13 19:24
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)7-Nov-13 19:24 
GeneralMy vote of 4 Pin
Marco Bertschi7-Nov-13 5:50
protectorMarco Bertschi7-Nov-13 5:50 
AnswerRe: My vote of 4 Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)7-Nov-13 6:24
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)7-Nov-13 6:24 
AnswerRe: My vote of 4 Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)29-Nov-13 4:58
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)29-Nov-13 4:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.