Mac Excel Version and Mac Office Language settings
It can be useful to know what the Excel version and the Excel language is of the Excel application that opens your workbook so your code can do different things depending of the version/language.
Note: Read also this page Test if it is a Mac or a Windows Machine
Note: Read also this page Test if it is a Mac or a Windows Machine
Excel version number
You can use Application.Version to get the version number of Excel as a string. We can use the Val function in Excel to make it numeric so we can test the number. Note that Win Excel give you always a whole number like 16 and Mac Excel will give you also the update number like 16.65 for example.
The macro below will display a msgbox with the Excel version, working in Excel for Windows also, you can replace the msgbox line with your code or a Macro call.
The macro below will display a msgbox with the Excel version, working in Excel for Windows also, you can replace the msgbox line with your code or a Macro call.
More Information
In Mac Office 2016 they add a new conditional compiler constant named MAC_OFFICE_VERSION. In most cases you can test the Application.Version(>=15) if you want, but in the macro above I use it for testing if it is a Mac and Excel 2016 or higher in one step.
But if you want to avoid compile errors with for example ribbon macro callbacks in Excel 2011(this not compile for example in 2011: control As IRibbonControl) or use VBA functions that are new in 2016 like AppleScriptTask and GrantAccessToMultipleFiles, you can add the ribbon macro callbacks or the new VBA functions in between the two code lines below in your code module.
#If MAC_OFFICE_VERSION >= 15 Then
Put your macro callbacks or code here
#End If
Note : Excel 2019 and higher and Microsoft Excel 365 on the Mac and Windows all give you number 16
Note: Mac Excel will not give you a whole number like Win Excel but also give you the update number.
Note: You see that Mac Excel 2016 can be version number 15.? or 16.?, but if you are up to date with Mac Excel 2016 you always have version 16.
If you also want to test on the whole number on your Mac you can use this :
Int(Val(Application.Version))
You can also use this WorksheetFunction to get the Excel version number
=INFO("release")
Laguage ID of Excel
f you want to know the exact language of the userinterface of Excel you can use this to return the language ID number in Excel for Windows and in Excel 2016 for the Mac version 16 or higher but it is not working on a Mac in the older Excel versions <16 :
Application.LanguageSettings.LanguageID(msoLanguageIDUI)
But I found this when I was looking in the VBE editor and it seems to give the same result in Mac Office 2011 and in version 15 of Excel 2016.
Application.LocalizedLanguage
To find the Decimal ID for every language visit this Microsoft page for example, there are many more sources on the internet : Language Identifier List
You can use Select Case now to run different code for each language, for example to display the captions of your buttons in the correct language or something else.
The Example below will work in Mac Excel 2011 and higher
Note that I replace msoLanguageIDUI for 2 in the code below so it compile in version 15
Application.LanguageSettings.LanguageID(msoLanguageIDUI)
But I found this when I was looking in the VBE editor and it seems to give the same result in Mac Office 2011 and in version 15 of Excel 2016.
Application.LocalizedLanguage
To find the Decimal ID for every language visit this Microsoft page for example, there are many more sources on the internet : Language Identifier List
You can use Select Case now to run different code for each language, for example to display the captions of your buttons in the correct language or something else.
The Example below will work in Mac Excel 2011 and higher
Note that I replace msoLanguageIDUI for 2 in the code below so it compile in version 15