Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Installed Excel Version (and Service Packs)

Tags:

excel

vb.net

I need to be able to detect which version of Excel I have installed in my machine from some .NET code I'm developing. I'm currently using Application.Version for that, but it doesn't give me information about Service Packs.

I would preferably to steer away from something like this: http://www.mvps.org/access/api/api0065.htm

Managed code welcomed!

like image 717
Román Avatar asked May 13 '09 16:05

Román


1 Answers

Public Shared Function GetExcelVersion() As Integer
    Dim excel As Object = Nothing
    Dim ver As Integer = 0
    Dim build As Integer
    Try
        excel = CreateObject("Excel.Application")
        ver = excel.Version
        build = excel.Build
    Catch ex As Exception
        'Continue to finally sttmt
    Finally
        Try
            Marshal.ReleaseComObject(excel)
        Catch
        End Try
        GC.Collect()
    End Try
    Return ver
End Function

Returns 0 if excel not found.

like image 133
Shimmy Weitzhandler Avatar answered Oct 17 '22 03:10

Shimmy Weitzhandler