Invoking Keymanapi from VBA

Hello to all,

After much delay I am now using a lull of activity during the holiday period to try and convert a MS-Access VBA application that programmatically invokes Keyman (V9) though the old kmcomapi library to a system using the latest version of keyman (V13) using keymanapi.

To make a long story short - this is a multilingual database and the keyboard needs to be automatically changed in some fields based on the value of other fields. So if field A is “Russian” for example then field B should shift to a cyrillic keyboard…if field A is “Hindi” then field B should shift to a Devanagari keyboard…etc…

In any case I have started to look at the API documentation at a link Mark gave me a while back: https://help.keyman.com/developer/engine/desktop/10.0/api/

But (lack of programming experience I suppose) I’m struggling on how to use this from VBA.
Are there any examples I could get my hands on, something along the lines of https://help.keyman.com/knowledge-base/93 for V9/kmcomapi ?

Any hints / links would be greatly appreciated ! :slight_smile:

Den

Please hold on as our developers are on leave till early next year. Thanks.

Hi Makara,
Of course, no rush :slight_smile:
Thanks

I’ve just returned from holiday and am now working through my backlog :slight_smile:

The best way to do this now doesn’t require the Keyman API but rather activates keyboards based on the Windows language using the Windows ActivateKeyboardLayout API. The Keyman keyboard will be activated when you use the Windows API. For VBA, you would use the code from KB0093 that you referenced.

You can use the ShowLoadedLayouts() function to list the identifier for each layout that you have loaded on your system, and then copy the SwitchKhmerOn() function, using the appropriate identifier for the keyboard you wish to activate.

See also https://stackoverflow.com/a/40942959/1836776. Note that this is the same as you referenced in KB0093 but the additional background at that link may be helpful.