Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    856
    Thanks
    0
    Thanked 9 Times in 8 Posts

    Windows Language Code

    I need to determine the Windows Language setting using Word 2010 VBA. I have a mix of Win7 and Win XP, but the code I have using Lib gdi32 doesn't seem to work in Win 7. I tested in WinXP as well, and it doesn't function. Is that a standard library? I see that Excel has Application.International(xlCountryCode); that would be of help, but there's apparently no equivalent in Word.

    I need to determine whether the Windows language is Japanese or Chinese (or not).

    Thanks.
    Last edited by richardbarrett; 2013-01-25 at 16:51.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,053
    Thanks
    196
    Thanked 759 Times in 694 Posts
    Richard,

    This MS Table will give you the language codes.
    You can query the document language with:
    Code:
    selection.languageid
    .

    I tried this in an immediate window after setting the proofing language of my work to PRC Chineese and got a return of 2052.
    Form the table in the link above:
    LanguageCodes.PNG

    Here's an article on setting the Proofing Language.

    HTH
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  4. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    856
    Thanks
    0
    Thanked 9 Times in 8 Posts
    Thanks, but I'm looking for the Windows language, not the document language. I would like to do this without using and API call. Excel has a command that returns the Windows language setting, but Word apparently does not.

  5. #4
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Dallas, Texas, USA
    Posts
    111
    Thanks
    2
    Thanked 5 Times in 5 Posts
    The Windows API function you need is either
    Code:
    GetSystemDefaultUILanguage
    , which is documented at http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx, or
    Code:
    GetUserDefaultUILanguage
    , documented at http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    The VBA declarations are as follows.

    Code:
    Public Declare Function GetSystemDefaultLanguage 
                                    Lib "kernel32" 
                                    Alias "GetSystemDefaultLangID" () 
                                            As Integer
    
    Public Declare Function GetUserDefaultUILanguage
                                    Lib "kernel32" 
                                    Alias "GetSystemDefaultLangID" () 
                                            As Integer
    Both function should be available on all versions of Microsoft Windows, since the documentation makes no mention of it being deprecated.
    David Gray, Chief Wizard
    WizardWrx
    Irving, Texas, USA

    WizardWrx Web - Technical Articles and Free Software
    You are more important than any technology we may employ.

  6. #5
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    856
    Thanks
    0
    Thanked 9 Times in 8 Posts
    I see that in Word, System.CountryRegion returns this value.

  7. #6
    5 Star Lounger
    Join Date
    Dec 2009
    Location
    Rochdale, UK
    Posts
    824
    Thanks
    13
    Thanked 52 Times in 52 Posts
    Quote Originally Posted by richardbarrett View Post
    I see that in Word, System.CountryRegion returns this value.
    Interesting. Using Word 2010 under W8 the value returned is our international dialling code

    ws3.PNG

  8. #7
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Willow Grove, Pennsylvania, USA
    Posts
    195
    Thanks
    4
    Thanked 45 Times in 37 Posts
    The System.CountryRegion property returns values from the enumeration WdCountry. If you compare the numeric values of the enumeration to a list of dialing codes, you'll see that they're mostly identical (wdUS = 1, wdCanada = 2, wdUK = 44, etc.). However, there are only 24 CountryRegion values, compared to well over 100 dialing codes, so many countries aren't represented at all. All of the Central American countries, which have dialing codes in the 500 range, are lumped together as wdLatinAmerica = 3.

    The System.LanguageDesignation property (http://msdn.microsoft.com/en-us/libr...ice.14%29.aspx) might be useful for the original topic of this thread.
    Last edited by jjfreedman; 2013-04-14 at 19:17.

Posting Permissions

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