Determine application language in Excel 97

P

Paul

Hi,

I have an application in which I need to detect the language version of the
Excel installation. To do this I use:

application.LanguageSettings.LanguageID(msoLanguageIDUI)

The problem is that some of the users have Excel 97 which doesn't seem to
support the LanguageSettings method.

Is there a method of determining the language version of Excel that will
work on all versions for 97 through 2003?

Thanks

Paul
 
B

Bob Phillips

Paul,

Here is another way. Put this code in a general module and access with


msgbox GetLanguageName()


'---------------------------

Private Declare Function GetThreadLocale Lib "kernel32" () As Long

Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long

Private Declare Function GetLocaleInfo Lib "kernel32" _
Alias "GetLocaleInfoA" _
(ByVal Locale As Long, _
ByVal LCType As Long, _
ByVal lpLCData As String, _
ByVal cchData As Long) As Long

Const LOCALE_ILANGUAGE As Long = &H1 'language id
Const LOCALE_SLANGUAGE As Long = &H2 'localized name of lang
Const LOCALE_SENGLANGUAGE As Long = &H1001 'English name of lang
Const LOCALE_SABBREVLANGNAME As Long = &H3 'abbreviated lang name
Const LOCALE_SNATIVELANGNAME As Long = &H4 'native name of lang
Const LOCALE_ICOUNTRY As Long = &H5 'country code
Const LOCALE_SCOUNTRY As Long = &H6 'localized name of country
Const LOCALE_SENGCOUNTRY As Long = &H1002 'English name of country
Const LOCALE_SABBREVCTRYNAME As Long = &H7 'abbreviated country name
Const LOCALE_SNATIVECTRYNAME As Long = &H8 'native name of country
Const LOCALE_SINTLSYMBOL As Long = &H15 'intl monetary symbol
Const LOCALE_IDEFAULTLANGUAGE As Long = &H9 'def language id
Const LOCALE_IDEFAULTCOUNTRY As Long = &HA 'def country code
Const LOCALE_IDEFAULTCODEPAGE As Long = &HB 'def oem code page
Const LOCALE_IDEFAULTANSICODEPAGE As Long = &H1004 'def ansi code page
Const LOCALE_IDEFAULTMACCODEPAGE As Long = &H1011 'def mac code page

Const LOCALE_IMEASURE As Long = &HD '0 = metric, 1 = US

'#if(WINVER >= &H0400)
Const LOCALE_SISO639LANGNAME As Long = &H59 'ISO abbreviated language name
Const LOCALE_SISO3166CTRYNAME As Long = &H5A 'ISO abbreviated country name
'#endif /* WINVER >= as long = &H0400 */

'#if(WINVER >= &H0500)
Const LOCALE_SNATIVECURRNAME As Long = &H1008 'native name of currency
Const LOCALE_IDEFAULTEBCDICCODEPAGE As Long = &H1012 'default ebcdic code
page
Const LOCALE_SSORTNAME As Long = &H1013 'sort name
'#endif /* WINVER >= &H0500 */

Dim LCID As Long

'---------------------------------------------------------------------------
Public Function GetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType
As Long) _
As String
'---------------------------------------------------------------------------

Dim sReturn As String
Dim r As Long

'call the function passing the Locale type
'variable to retrieve the required size of
'the string buffer needed
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))

'if successful..
If r Then

'pad the buffer with spaces
sReturn = Space$(r)

'and call again passing the buffer
r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))

'if successful (r > 0)
If r Then

'r holds the size of the string
'including the terminating null
GetUserLocaleInfo = Left$(sReturn, r - 1)

End If

End If

End Function

'---------------------------------------------------------------------------
Public Function GetLanguageName()
'---------------------------------------------------------------------------

LCID = GetSystemDefaultLCID()

GetLanguageName = GetUserLocaleInfo(LCID, LOCALE_SENGLANGUAGE)
End Function

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top