Is Excel installed and what version?


In this VB.Net Tutorial/Code Example, I’m going to provide you with a simple class that allows for you to check whether Excel is installed on the computer and also figure out which version of the Excel it is.

The version function uses late binding.

Imports Microsoft.Win32

Namespace MS.Office
    Public Class Excel
        Public Shared Function isInstalled() As Boolean
            Dim regClasses As RegistryKey = Registry.ClassesRoot
            Dim rtn As Boolean
            Dim reg As RegistryKey = regClasses.OpenSubKey("Excel.Application")
            If reg Is Nothing Then
                rtn = False
                rtn = True
            End If

            Return rtn
        End Function

        Public Shared Function version() As String
            Dim rtn As String = ""
            Dim objApp As Object

            If isInstalled() Then
                objApp = CreateObject("Excel.Application")
                rtn = objApp.Version
            End If

            Return rtn
        End Function
    End Class
End Namespace