How to get the user's language in Excel with VBA?

Viewed 781

I need to get the user's language in Excel through VBA, as far as Excel does not automatically translate Pivot tables and I am searching within a Pivot with VBA.

Just found out that in German the Pivot looks like this:

enter image description here

While in English it is like this:

enter image description here

I can think about an option, writing a =VLOOKUP() formula in Excel and checking whether the words are actually "Vlookup" or whether they are =SVERWEIS() and based on the result decide whether it is German or English.

Anyway, this looks too "ugly". Are there any better ideas?

3 Answers

Another option would be to check the Application.International property. For example making use of xlCountryCode:

Application.International(xlCountryCode)

After testing with 2 Excels (English & German), what has been proved to work is:

Application.International(xlCountryCode)

returning the following for the different Excel countries versions:

Note - the following does not work and is dangerous:

  • Application.LanguageSettings.LanguagePreferredForEditing(msoLanguageIDEnglishUS)

  • Application.LanguageSettings.LanguageID(msoLanguageIDInstall)

  • Application.LanguageSettings.LanguageID(msoLanguageIDExeMode)

Probably it looks not at the language of your excel, but at the language of your Windows, which can be different, as in my own PC:

enter image description here

Try, please:

Application.LanguageSettings.LanguageID(msoLanguageIDInstall)

or

Application.LanguageSettings.LanguageID(msoLanguageIDExeMode)

in case they return differently...

Related