Home All Groups Group Topic Archive Search About

How to check Excel version number with .net?

Author
4 Jan 2006 8:28 PM
Alain "Mbuna\
Hi everybody.

Does anyone know what code I should use to check for the version number of
Excel, installed on a computer?

Thanks.

Alain.

Author
5 Jan 2006 4:30 PM
Paul Clement
On Wed, 04 Jan 2006 20:28:30 GMT, "Alain \"Mbuna\"" <mb***@telenet.be> wrote:

¤ Hi everybody.
¤
¤ Does anyone know what code I should use to check for the version number of
¤ Excel, installed on a computer?
¤

You can also use the FindExecutable API function call (which doesn't launch the Excel application):

    Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As
String, _
                                                                                ByVal lpDirectory As
String, _
                                                                                ByVal lpResult As
System.Text.StringBuilder) As Int32

    Function IsExcelInstalled(ByRef FileVersionMajor As String) As Boolean

        Dim DummyFile As String
        Dim FileDir As String

        Dim FilePath As New System.Text.StringBuilder(255)
        DummyFile = "e:\My Documents\book1.xls"

        If FindExecutable(DummyFile, FileDir, FilePath) > 32 Then
            IsExcelInstalled = True
            FileVersionMajor =
System.Diagnostics.FileVersionInfo.GetVersionInfo(FilePath.ToString).FileMajorPart
        End If

    End Function


Paul
~~~~
Microsoft MVP (Visual Basic)