1

I am running this code in VBA Excel 365 using Windows 11

Sub test()
Dim sBuild As String, sOP As String, sVersion As String

sBuild = Application.Build
sOP = Application.OperatingSystem
sVersion = Application.Version
MsgBox "Operating System " & sOP & " with Office version " & sVersion & " Build " & sBuild

End Sub

However, I get this message "Operating System Windows (64-bit) NT 10.00 with Office version 16.0 Build 15028"

The properties Application.Version and Application.OperatingSystem shows the same results as if I was running in Excel 2016 and using Windows 10.

Any suggestion to get the real Office and Windows version?

Thank you.

Manuel

  • What do you expect `Application.Version` to return for Excel 365? – BigBen Apr 07 '22 at 16:13
  • 1
    See a possible example for versions 2016+ up to MS 365 at [Check the application version in modern office](https://www.excelguru.ca/blog/2019/02/11/check-the-application-version-in-modern-office/) – T.M. Apr 07 '22 at 19:31
  • 1
    Further link you might be interested in: [Detect if dynamic arrays is enabled in Excel version with VBA](https://stackoverflow.com/questions/70842787/detect-if-dynamic-arrays-is-enabled-in-excel-version-with-vba/70843490#70843490) – T.M. Apr 07 '22 at 19:35
  • 1
    These links were usefull. Thank you. – Manuel Pérez Apr 08 '22 at 18:18

1 Answers1

3

This link in the comment above works fine for Office (Check the application version in modern office).

I use this for Windows:

Function GetWindowsInfo() As String
  Dim oShell As Object
  Set oShell = CreateObject("WScript.Shell")
  Dim RegKeyProduct As String
  RegKeyProduct = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName"
  Dim ProductName As String
  ProductName = oShell.RegRead(RegKeyProduct)
  Dim VersionBuildNumbers(1 To 4) As Variant
  Dim RegKeyMajor As String
  RegKeyMajor = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentMajorVersionNumber"
  VersionBuildNumbers(1) = oShell.RegRead(RegKeyMajor)
  Dim RegKeyMinor As String
  RegKeyMinor = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentMinorVersionNumber"
  VersionBuildNumbers(2) = oShell.RegRead(RegKeyMinor)
  Dim RegKeyBuild As String
  RegKeyBuild = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuildNumber"
  VersionBuildNumbers(3) = oShell.RegRead(RegKeyBuild)
  If VersionBuildNumbers(3) >= 22000 Then
    ProductName = Replace(ProductName, "10", "11")
  End If
  Dim RegKeyUBR As String
  RegKeyUBR = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\UBR"
  VersionBuildNumbers(4) = oShell.RegRead(RegKeyUBR)
  Dim BuildNumber As String
  BuildNumber = oShell.RegRead(RegKeyBuild) & "." & oShell.RegRead(RegKeyUBR)
  Dim Bitness As String
  Bitness = "32-bit"
  If Len(Environ("PROGRAMFILES(x86)")) Then Bitness = "64-bit"
  GetWindowsInfo = "Microsoft " & ProductName & " (" & Join(VersionBuildNumbers, ".") & ") " & Bitness
End Function
Jon Peltier
  • 5,895
  • 1
  • 27
  • 27