Microsoft Excel

Ron de Bruin
Excel Automation

Microsoft MVP Program

Excel version and Office language settings

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

 

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 see
http://support.microsoft.com/kb/213833/en-us

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-2013

 

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)

Note: This is not working in Mac Office, you can use this to get the same result in Mac Office : http://www.rondebruin.nl/mac/mac002.htm

 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 2011 for the Mac :

Mac Excel version and Mac Office language settings