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 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. In the macro below you see i use If Val(Application.Version) < 15 Then to be sure that it is not Mac Excel 2016.

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)
    #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 there is also a function that you can use for this and also a function 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.7 (when I create this page with Office up to date)
Mac Excel 2016 = 15.29 (when I create this page with Office up to date)

You see that Excel for the Mac will not give you a whole number like the Windows versions. The Val function will make it numeric so you can test the value in your code.
If you also want to test on the whole number on your Mac you can use this :

Int(Val(Application.Version))

Note : You see that Excel 2011 for the Mac and Excel 2010 for Windows use both 14 in the version number, and Excel 2016 for the Mac and Excel 2013 for Windows use both 15 in the version number. Very easy <g>

 

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 but this is not working on a Mac:
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.

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.

Sub Test2()
    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 Sub

If you have problems with the code please report it so I can update this page.