Consulting

Results 1 to 2 of 2

Thread: Get current keyboard layout with VBA

  1. #1
    VBAX Regular
    Joined
    Sep 2010
    Posts
    28
    Location

    Arrow Get current keyboard layout with VBA

    (This post is cross-posted from: http://www.mrexcel.com/forum/showthread.php?t=541054)
    Hi all.

    How can I get the current keyboard layout (language code)?

    I'm asking this because when "Application.OnKey" tries to assign a key combination, which contains a character in other layout than the active, it will result run-time error 1004 with the following message:
    Method 'OnKey' of object '_Application' failed
    So I want to check the layout first, before running "Application.OnKey".
    And I wonder, can Excel listen and know when the keyboard layout gets changed?

    Thanks in advance, Meir.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    You might be able to use the .International property, but I'n not sure if it picks up keyboard changes


    Application.International Property
    Returns information about the current country/region and international settings. Read-only Variant.

    xlCountryCodeLongCountry/Region version of Microsoft Excel.
    xlCountrySettingLongCurrent country/region setting in the Windows Control Panel.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •