Detect MacOS version number

Sometimes as a developer you want to be sure that the Mac your VBA code is running on have the correct MacOS version installed so your code is working correct. With the macro example below you can test the MacOS version.

On the moment I created this page my MacOS version (Big Sur) = 11.0

Mac OS X 10.0 Cheetah
Mac OS X 10.1 Puma
Mac OS X 10.2 Jaguar
Mac OS X 10.3 Panther
Mac OS X 10.4 Tiger
Mac OS X 10.5 Leopard
Mac OS X 10.6 Snow Leopard
Mac OS X 10.7 Lion
OS X 10.8 Mountain Lion
OS X 10.9 Mavericks
OS X 10.10 Yosemite
OS X 10.11 El Capitan
MacOs 10.12 Sierra
MacOs 10.13 High Sierra
MacOs 10.14 Mojave
MacOs 10.15 Catalina
MacOs 11.0 Big Sur

In the Mac Office 2016 version they changed the string that is returned by Application.OperatingSystem so I looked for another solution that is working in Office. The macro example below I test if Catalina is installed.

Sub TestMacOSVersion()
'Example to test if Catalina is installed (10.15)
Dim OSstring As String
Dim MySplit As Variant

OSstring = MacScript("do shell script ""sw_vers -productVersion""")
MySplit = Split(OSstring, ".")

If Val(MySplit(0)) = 10 And Val(MySplit(1)) = 15 Then
MsgBox "This is macOS Catalina"
MsgBox "Sorry you not have Catalina as macOS"
End If

' For information and testing only I add the three lines below
' Note : If you want to know the exact Update number you can
' also use Val(MySplit(2)) in the If line if that is important

MsgBox MySplit(0)
MsgBox MySplit(1)
'MsgBox MySplit(2)
End Sub
Web design by Will Woodgate