Microsoft Excel

Ron de Bruin
Excel Automation

Microsoft MVP Program

Mac Excel version and Mac Office language settings

Introduction

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

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.

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.

Sub TestMacOrWindowsOfficeVersion()
'Test the conditional compiler constants
    #If MAC_OFFICE_VERSION >= 15 Then
        MsgBox "Excel 2016 for the Mac, version: " & _
            Val(Application.Version)
        Exit Sub
    #End If
    
    #If Mac Then
        If Val(Application.Version) < 15 Then
            MsgBox "Excel 2011 or earlier for the Mac, version: " & _
                Val(Application.Version)
        End If
    #Else
        MsgBox "Excel for Windows, version: " & _
            Val(Application.Version)
    #End If
End Sub

On this page you can also find a UDF function that you can use for this and also a UDF to test if the Office version is 32 or 64 bit : Test if it is a Mac or a Windows Machine

Note: In Mac Office 2016 they add a new conditional compiler constant named MAC_OFFICE_VERSION. In most cases you can also test the Application.Version(>=15) to know if your code is runing in Excel 2016.

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

Excel for Windows always give you a string with the whole number, this are the Windows Excel versions :

Excel 97 = 8
Excel 2000 = 9
Excel 2002 = 10
Excel 2003 = 11
Excel 2007 = 12
Excel 2010 = 14
Excel 2013 = 15
Excel 2016 = 16

Note: Mac Excel will not give you a whole number :

Mac Excel 2011 = 14.?

Mac Excel 2016 = 15.? (when I was released but now it is version 16 if you are up to date, see below)

Mac Excel 2016 = 16.11.1 (24-March-2018)

Note: You see that Excel 2016 can be version number 15.? or 16.?, but if you update Excel 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))

 

Language ID of Excel

If 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 ID for every language visit :http://support.microsoft.com/kb/221435

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 Excel 2011 and all versions of 2016 for the Mac

Note that I replace msoLanguageIDUI for 2 in the code below so it compile in version 15

Sub Test()
    If Val(Application.Version) >= 16 Then
    ' You use Mac Excel version 16 or higher
        Select Case Application.LanguageSettings.LanguageID(2)
            Case 1031: MsgBox "Run code for German"
            Case 1034: MsgBox "Run code for Spanish"
            Case 1036: MsgBox "Run code for French"
            Case 1043: MsgBox "Run code for Dutch"
            Case 1049: MsgBox "Run code for Russian"
            Case Else: MsgBox "Run code for English US(default 1033)"
        End Select
    Else
        ' You use Mac Excel version 15 or lower
        Select Case Application.LocalizedLanguage
            Case 1031: MsgBox "Run code for German"
            Case 1034: MsgBox "Run code for Spanish"
            Case 1036: MsgBox "Run code for French"
            Case 1043: MsgBox "Run code for Dutch"
            Case 1049: MsgBox "Run code for Russian"
            Case Else: MsgBox "Run code for English US(default 1033)"
        End Select
    End If
End Sub