Microsoft Excel Version Validation (Office 2007)

Posted by Naimishforu under VB.NET category on | Points: 40 | Views : 2629
Microsoft Excel Version Validate :

    Private Sub GetExcelVersions()

Dim _excelPath As String = GetComponentPath(OfficeComponent.Excel)

If Not GetMajorVersion(_excelPath) = 12 Then
System.Windows.MessageBox.Show("Please Note: Only Computers which are using Microsoft Excel 2007 can use this Application at this time. The Application will be closed.", "Microsoft Excel Version In Use Is Not Supported", MessageBoxButton.OK, MessageBoxImage.Exclamation)


End If

End Sub

Private Function GetMajorVersion(ByVal _path As String) As Integer
Dim toReturn As Integer = 0

If File.Exists(_path) Then


Dim _fileVersion As FileVersionInfo = FileVersionInfo.GetVersionInfo(_path)
toReturn = _fileVersion.FileMajorPart


End Try

End If

Return toReturn

End Function

Comments or Responses

Login to post response