'reprise du module clavier @Dudu2 sur exceldownload
'les api avec les macro4
'patricktoulon 04/08/2021
Option Explicit
'---------------------------------
'Retourne True si clavier français
'---------------------------------
Function ClavierEstFrançais() As Boolean
Dim KeyboardLayout As Long
KeyboardLayout = ExecuteExcel4Macro("CALL(""user32"",""GetKeyboardLayout"",""JJ""," & 0 & ")")
ClavierEstFrançais = True
'https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-input-locales-for-windows-language-packs
Select Case KeyboardLayout
Case &H484040C 'Alsatian - France
Case &H47E040C 'Breton - France
Case &H483040C 'Corsican - France
Case &H80C080C 'French - Belgium
Case &H40C040C 'French - France (AZERTY)
Case &H140C100C 'French - Luxembourg
Case &H180C040C 'French - Monaco
Case &H100C100C 'French - Switzerland
Case &H482040C 'Occitan - France
Case Else
ClavierEstFrançais = False
End Select
End Function
Sub test()
MsgBox ClavierEstFrançais
End Sub
'----------------------------------
'Met le clavier en anglais (QWERTY)
'----------------------------------
Sub MetClavierEnAnglais()
ExecuteExcel4Macro ("CALL(""user32"",""LoadKeyboardLayoutA"",""JCJ"",""00000409""," & &H1 & ")")
End Sub
'-----------------------------------
'Met le clavier en français (AZERTY)
'-----------------------------------
Sub MetClavierEnFrançais()
ExecuteExcel4Macro ("CALL(""user32"",""LoadKeyboardLayoutA"",""JCJ"",""0000040C""," & &H1 & ")")
End Sub