Option Explicit
Private Type LangCode
English As Boolean
French As Boolean
Spanish As Boolean
Arabic As Boolean
[COLOR=seagreen][B]'add other languages here...[/B][/COLOR]
End Type
Private Const KL_NAMELENGTH As Long = 9
Private Declare Function GetKeyboardLayoutName Lib "user32" _
Alias "GetKeyboardLayoutNameA" ( _
ByVal pwszKLID As String) As Long
Sub Test()
Const MSG As String = _
"The KeyBoard Language for the current Process is : "
If KeyboardLanguage.English Then
MsgBox MSG & "'English'"
ElseIf KeyboardLanguage.French Then
MsgBox MSG & "'French'"
ElseIf KeyboardLanguage.Spanish Then
MsgBox MSG & "'Spanish'"
ElseIf KeyboardLanguage.Arabic Then
MsgBox MSG & "'Arabic'"
[COLOR=seagreen][B]'ElseIf .......[/B][/COLOR]
Else
MsgBox "Unknown Keyboard Language."
End If
End Sub
Private Function KeyboardLanguage() As LangCode
Dim tLC As LangCode
Dim sBuffer As String
sBuffer = Space(KL_NAMELENGTH - 1)
GetKeyboardLayoutName sBuffer
Select Case Right(sBuffer, 2)
Case "09"
tLC.English = True
Case "0C"
tLC.French = True
Case "0A"
tLC.Spanish = True
Case "01"
tLC.Arabic = True
End Select
KeyboardLanguage = tLC
End Function