Determine language of user

cycle_simon

Board Regular
Joined
Jun 13, 2007
Messages
56
Our office has staff who work in either English or French. I have set up a userform to collect data but need to show an English version to those who's Excel/MSOffice is English and a French Userform to those who work in French.

How do you determine the language of the user from an Excel macro?

Thanks for the suggestions.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try

French

Code:
If Application.International(xlCountryCode) = 33 Then ......

U.S. English

Code:
If Application.International(xlCountryCode) = 1 Then ......

Edit:-

List of supported country codes http://support.microsoft.com/kb/213833
 
Last edited:
Upvote 0
Try

French

Code:
If Application.International(xlCountryCode) = 33 Then ......

U.S. English

Code:
If Application.International(xlCountryCode) = 1 Then ......

Edit:-

List of supported country codes http://support.microsoft.com/kb/213833


Thanks Jason for the quick response. In canvassing the users I have realized that there is another situation where MSOffice is installed in English, but the user has a French language keyboard. Is there a property that can deterimine the language of the keyboard?

Where would I look for these keywords/properties in Excel?

Thanks
 
Upvote 0
There are a few examples of this on the web. This is basically a quick chop from here: http://vbnet.mvps.org/index.html?code/locale/getkeyboardlayout.htmhttp://vbnet.mvps.org/index.html?code/locale/localecountry.htm

Code:
[COLOR=blue]Private[/COLOR] [COLOR=blue]Const[/COLOR] LOCALE_ILANGUAGE [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR] = &H1
[COLOR=blue]Private[/COLOR] [COLOR=blue]Const[/COLOR] LOCALE_SCOUNTRY [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR] = &H6
 
[COLOR=blue]Private[/COLOR] [COLOR=blue]Declare[/COLOR] [COLOR=blue]Function[/COLOR] GetKeyboardLayout [COLOR=blue]Lib[/COLOR] "user32" _
    ([COLOR=blue]ByVal[/COLOR] dwLayout [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]
 
[COLOR=blue]Private[/COLOR] [COLOR=blue]Declare[/COLOR] [COLOR=blue]Function[/COLOR] GetLocaleInfo [COLOR=blue]Lib[/COLOR] "kernel32" _
    [COLOR=blue]Alias[/COLOR] "GetLocaleInfoA" _
    ([COLOR=blue]ByVal[/COLOR] Locale [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR], _
    [COLOR=blue]ByVal[/COLOR] LCType [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR], _
    [COLOR=blue]ByVal[/COLOR] lpLCData [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR], _
    [COLOR=blue]ByVal[/COLOR] cchData [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]
 
[COLOR=blue]Public[/COLOR] [COLOR=blue]Sub[/COLOR] ShowLangauges()
    [COLOR=blue]Dim[/COLOR] hKeyboardID [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]
    [COLOR=blue]Dim[/COLOR] LCID [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]
 
    hKeyboardID = GetKeyboardLayout(0&)
    [COLOR=blue]If[/COLOR] hKeyboardID > 0 [COLOR=blue]Then[/COLOR]
        LCID = LoWord(hKeyboardID)
        [COLOR=blue]Debug.Print[/COLOR] GetUserLocaleInfo(LCID, LOCALE_ILANGUAGE)
        [COLOR=blue]Debug.Print[/COLOR] GetUserLocaleInfo(LCID, LOCALE_SCOUNTRY)
    [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]
 
[COLOR=blue]Private[/COLOR] [COLOR=blue]Function[/COLOR] LoWord(wParam [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]Integer[/COLOR]
    [COLOR=blue]If[/COLOR] wParam [COLOR=blue]And[/COLOR] &H8000& [COLOR=blue]Then[/COLOR]
        LoWord = &H8000& [COLOR=blue]Or[/COLOR] (wParam [COLOR=blue]And[/COLOR] &H7FFF&)
    [COLOR=blue]Else[/COLOR]
        LoWord = wParam [COLOR=blue]And[/COLOR] &HFFFF&
    [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
 
[COLOR=blue]Public[/COLOR] [COLOR=blue]Function[/COLOR] GetUserLocaleInfo([COLOR=blue]ByVal[/COLOR] dwLocaleID [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR], _
                                  [COLOR=blue]ByVal[/COLOR] dwLCType [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]) [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
    [COLOR=blue]Dim[/COLOR] sReturn [COLOR=blue]As[/COLOR] [COLOR=blue]String[/COLOR]
    [COLOR=blue]Dim[/COLOR] nSize [COLOR=blue]As[/COLOR] [COLOR=blue]Long[/COLOR]
    nSize = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, [COLOR=blue]Len[/COLOR](sReturn))
    [COLOR=blue]If[/COLOR] nSize > 0 [COLOR=blue]Then[/COLOR]
        sReturn = [COLOR=blue]Space$[/COLOR](nSize)
        nSize = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, [COLOR=blue]Len[/COLOR](sReturn))
        [COLOR=blue]If[/COLOR] nSize > 0 [COLOR=blue]Then[/COLOR]
            GetUserLocaleInfo = [COLOR=blue]Left$[/COLOR](sReturn, nSize - 1)
        [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
    [COLOR=blue]End[/COLOR] [COLOR=blue]If[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Function[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,250
Members
451,756
Latest member
tommyw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top