How to retrieve Operating System Information using Excel/Word VBA
The version information of OS can be retrieved using the WIN API functions given below
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpVersionInformation As _
OSVERSIONINFO) As Long
The following sub uses GetVersionEx function to get the Major and Minor version of OS
Sub Get_OS_Version_VBA()
' -------------------------------------------------------------
' Code to Get Version of Operating System through VBA
' -------------------------------------------------------------
Dim oOSInfo As OSVERSIONINFO
oOSInfo.dwOSVersionInfoSize = Len(oOSInfo)
GetVersionEx oOSInfo
' -------------------------------------------------------------
' Coded for http://vbadud.blogspot.com
' -------------------------------------------------------------
MsgBox "Version of Current OS is " & oOSInfo.dwMajorVersion & "." & oOSInfo.dwMinorVersion
End Sub