Hello you can do what you have said with the macros.
Following this older knowledge base.
Here are the functions I adapted for my install which had a Khmer and Greek keyboard.
I determined the Greek keyboard had the id 4090408 and the Khmer keyboard had the id 4090453. It is a working example.
The ShowLoadedLayouts function will show you the currently loaded keyboard layouts in your system. However, it just gives the HEX values without a descriptive name of the keyboard.
You can work out by using it in the macro function and observing which keyboard layout is loaded. If you are having trouble still I can post some instructions how to find these layout ids
using the Keyman Diagnostic tool.
It is best to have Keyman already running. If you want to have a macro to start keyman you can. I tried the function below LaunchKeyman and it worked.
'
' Keyboard switching in Visual Basic for Applications x64
' -------------------------------------------------------
'
Private Declare PtrSafe Function ActivateKeyboardLayout Lib "user32" (ByVal HKL As LongPtr, _
ByVal flags As Long) As Long
Private Declare PtrSafe Function GetKeyboardLayoutList Lib "user32" (ByVal size As Long, _
ByRef layouts As LongPtr) As Long
Sub SwitchKhmerOn()
Selection.Font.Name = "Khmer OS Content"
ActivateKeyboardLayout &H4090453, 0
End Sub
Sub SwitchGreekOn()
Selection.Font.Name = "Gentium Basic"
ActivateKeyboardLayout &H4090408, 0
End Sub
Sub SwitchsadKeyasamanOff()
Selection.Font.Name = "Arial"
ActivateKeyboardLayout &H4090C09, 0
End Sub
Sub ShowLoadedLayouts()
Dim numLayouts As Long
Dim i As Long
Dim layouts() As LongPtr
numLayouts = GetKeyboardLayoutList(0, ByVal 0&)
ReDim layouts(numLayouts - 1)
GetKeyboardLayoutList numLayouts, layouts(0)
Dim msg As String
msg = "Loaded keyboard layouts: " & vbCrLf & vbCrLf
For i = 0 To numLayouts - 1
msg = msg & Hex(layouts(i)) & vbCrLf
Next
MsgBox msg
End Sub
Sub LaunchKeyman()
Dim ProgramPath As String
ProgramPath = "c:\Program Files (x86)\Keyman\Keyman Desktop\kmshell.exe -s"
Shell ProgramPath, vbNormalNoFocus ' Launch the program
End Sub