LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Alternative solution

Thanks Nick for the answer. I have read the articles and they suggest to ask
the user to modify the regional settings. Seems not to be possible to modify
it from VBA. So, if the report is created in French, I'll use GetLocalInfo to
verify if all numbers and date settings are correct. If not, I'll ask the
user to modify the settings to put "French (canadian)". I'll open the control
panel box directly in Excel using:
Sub test()
Dim Cmdl As String
Cmdl = "rundll32.exe shell32.dll,Control_RunDLL intl.cpl" + ",,5"
Shell Cmdl$, vbNormalFocus
End Sub
I expect it should be compatible with all versions of window.
Thank you!
Alex
--
Alex St-Pierre


"NickHK" wrote:

Alex,
According to this article
http://vbnet.mvps.org/code/locale/setlocaleinfo.htm
LOCALE_IDEFAULTLANGUAGE is not a valid value for the LCType argument of
SetLocaleInfo.
And an MS article
http://msdn.microsoft.com/library/en...asp?frame=true
<Quote
LOCALE_IDEFAULTLANGUAGE
Obsolete. Do not use. This value was provided so that partially specified
locales could be completed with default values. Partially specified locales
are now deprecated.
</Quote

So, not sure how to change the locale, but not this way.

NickHK

"Alex St-Pierre" wrote in message
...
Hi,
I would like to modify the "Regional and Language Options"/"Standards and
Formats" from "french canadian" to "english canadian" using vba. I tried

to
modify "LOCALE_IDEFAULTLANGUAGE" value but it doesn't work. I have pasted

my
program. Does anyone know how to make it work.
Thank you!
Alex
Sub ModifyLanguage()
Dim Symbol As String
Dim iRet As Long
Dim Locale As Long
' Locale = GetSystemDefaultLCID()
Locale = GetUserDefaultLCID() 'Get user Locale ID
Symbol = "1009"
MsgBox GetInfo(LOCALE_IDEFAULTLANGUAGE) 'Give "0c0c"
Call SetLocaleInfo(Locale, LOCALE_IDEFAULTLANGUAGE, Symbol)
MsgBox GetInfo(LOCALE_IDEFAULTLANGUAGE) 'Still give "0c0c" ???
End Sub

Public Const LOCALE_USER_DEFAULT = &H400
Public Const LOCALE_SENGCOUNTRY = &H1002 ' English name of country
Public Const LOCALE_SENGLANGUAGE = &H1001 ' English name of language
Public Const LOCALE_SNATIVELANGNAME = &H4 ' native name of language
Public Const LOCALE_SNATIVECTRYNAME = &H8 ' native name of country
Public Const LOCALE_IDEFAULTCODEPAGE = &HB
Public Const LOCALE_IDEFAULTCOUNTRY = &HA
Public Const LOCALE_IDEFAULTLANGUAGE = &H9
Public Const LOCALE_ILANGUAGE = &H1
Public Const LOCALE_SLANGUAGE = &H2

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

Declare Function SetLocaleInfo Lib "kernel32" Alias _
"SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, _
ByVal lpLCData As String) As Boolean

Declare Function GetUserDefaultLCID% Lib "kernel32" ()

Public Function GetInfo(ByVal lInfo As Long) As String
Dim buffer As String, Ret As String
buffer = String$(256, 0)
Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, buffer, Len(buffer))
If Ret 0 Then
GetInfo = Left$(buffer, Ret - 1)
Else
GetInfo = ""
End If
End Function


--
Alex St-Pierre




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking dats on a worksheet to control panel sbearman Charts and Charting in Excel 0 June 25th 08 01:35 PM
Excel 2007 using control panel display settings Mark Excel Discussion (Misc queries) 0 June 12th 07 08:36 PM
Control panel detection Jags Excel Programming 2 February 14th 06 12:36 PM
Control Panel-Dual Display API Vacation's Over Excel Programming 2 September 18th 05 07:37 PM
Control Panel Matt Excel Programming 1 March 22nd 05 07:01 PM


All times are GMT +1. The time now is 08:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"