Microsoft Excel
Back to jkp-ads.com

Ron de Bruin
Excel Automation

Microsoft MVP Program

Excel version and Office language settings

Important message to visitors of this page

Ron de Bruin decided to remove all Windows Excel content from his website for personal reasons. If you want to know why, head over to rondebruin.nl.

Luckily, Ron was kind enough to allow me to publish all of his Excel content here.

Most of these pages are slightly outdated and may contain links that don 't work. Please inform me if you find such an error and I'll try to fix it.

Kind regards

Jan Karel Pieterse


The first thing I suggest you should do is read the "International Issues" chapter from the following link:
Excel 2002 VBA Programmer's Reference
Written by John Green, Stephen Bullen, Rob Bovey and Robert Rosenberg
http://www.oaltd.co.uk/ExcelProgRef/Ch22/default.htm

Note: see also the other pages about International Excel Issues on my site.

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.

 

Excel Version Number

You can use this to get the version number of Excel in any local : Val(Application.Version)

Sub Test()
    If Val(Application.Version) < 12 Then
        'You use Excel 97-2003
    Else
        'You use Excel 2007 or higher
    End If
End Sub

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

Excel 2019 and Excel 365 also give you number 16

You can use this test macro to test the real version, I hope to have a better version soon.

Sub TestExcelVersion_2016_2019_365()
    'Testcode for Excel 2016, 2019 and 365 in Win and Mac Excel
    'Application.version will display 16 for all versions
    Dim Answ As String
 
    If Int(Val(Application.Version)) = 16 Then
 
        On Error Resume Next
        'Test the xmatch function NEW in Excel 365
        Answ = Application.Evaluate("=XMATCH(5,{5,4,3,2,1})")
        If Err = 0 Then
            MsgBox "You run Excel 365"
        Else
            Err.Clear
            'Test the concat function NEW in Excel 2019
            Answ = Application.Evaluate("=CONCAT(""A"",""B"")")
            If Err = 0 Then
                MsgBox "You run Excel 2019"
            Else
                MsgBox "You run Excel 2016"
            End If
        End If
        
    End If
End Sub

 

Country code

You can use this to get the language chosen in Windows Regional Settings :
Application.International(xlCountrySetting)

This will give you the Country code, for example 31 for Dutch and 7 for Russian.
For a list of country codes do a Google Search because MS delete the information online.

You can use Select case to run the code you want like this

Sub Test1()
    Select Case Application.International(xlCountryCode)
    Case 31: MsgBox "Run code for Dutch"
    Case 7: MsgBox "Run code for Russian"
    Case Else: MsgBox "Run code for English (default)"
    End Select
End Sub

See how I use it on this page to create a Ribbon menu
Menu in the Ribbon with different languages in Excel 2007 and higher

 

Language ID of Excel

If you want to know the exact language of the userinterface of Excel (Because you can install many different language packs) you can use this to return the language ID number:
Application.LanguageSettings.LanguageID(msoLanguageIDUI)

To know what language belong the each ID press F2 in the VBA editor to open the object browser and enter msoLanguageID in the search field and press the search button. You see a long list now with language Id's. If you select one you can see the number on the bottom of the object browser. For example if I select "msoLanguageIDDutch" I see this on the bottom of the object browser :

Const msoLanguageIDDutch = 1043 (&H413)

You can use Select Case now in your code to run different code for a few languages, for example
to display the captions of your buttons in the correct language or anything else.

Sub Test2()
    Select Case Application.LanguageSettings.LanguageID(msoLanguageIDUI)
    Case 1043: MsgBox "Run code for Dutch"
    Case 1049: MsgBox "Run code for Russian"
    Case Else: MsgBox "Run code for English (default)"
    End Select
End Sub

Note : Not working in Mac Office, see my Mac page for another way to do this.

 

Application.International (VBA)

In the section above I use Application.International(xlCountryCode) to get the language chosen in Windows Regional Settings. But you can use it to get a lot more information about the users Excel application with this in your VBA code. If you search for Application.international in the VBA editor the Help will give a you a table with all the XlApplicationInternational constants that you can use in your code.

For example this code line will give you the local Year, Month and Day character

MsgBox "The Year, Month and Day Characters are " & _
    Application.International(xlYearCode) & " " & _
    Application.International(xlMonthCode) & " " & _
    Application.International(xlDayCode)


If you not want to use VBA to get this kind of information check out Get.workspace example workbook
on this page : International Worksheetfunction problems

 

Office for the Mac

Check out this page if you use Office for the Mac :

Mac Excel version and Mac Office language settings