none
Change regional settings from polish to US windows 10 RRS feed

  • Question

  • Hi,

    crossed posted here:

    Cross

    The code is:

    #If VBA7 Then    Private Declare PtrSafe Function SetThreadLocale Lib "kernel32" _        (ByVal Locale As Long) As Boolean    Private Declare PtrSafe Function GetUserDefaultLCID Lib "kernel32" () As Long    Private Declare PtrSafe Function LocaleNameToLCID Lib "kernel32" _        (ByVal lpName As LongPtr, dwFlags As Long) As Long#Else    Private Declare Function SetThreadLocale Lib "kernel32" (ByVal Locale As Long) As Boolean    Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long    Private Declare Function LocaleNameToLCID Lib "kernel32" _       (ByVal lpName As LongPtr, dwFlags As Long) As Long#End IfPrivate Sub Test() Dim userLocale As Long 'US settings numberuserLocale = GetUserDefaultLCID userLocale = 1033 SetThreadLocale userLocale End SubSo what i want is to change regional settings from windows default (in my case Polish) to us. Polish getUserDefaultLCID = 1045, US = 1033. 



    After running the code above nothing is happening, how to force windows 10 to set regional settings using VBA?
    Please help,
    Jacek




    Friday, February 15, 2019 9:16 AM

All replies

  • Hi jaryszek,

    Thank you for provideing code.  But it looks a single line.
    Would you insert [Return] adequately in Code Block?

    Regards,

    Ashidacchi -- https://ssl01.rocketnet.jp/hokusosha.com/default.html

    Friday, February 15, 2019 11:30 PM
  • Hi,

    whole code here (you could click on Cross post to see): 

    #If VBA7 Then
        Private Declare PtrSafe Function SetThreadLocale Lib "kernel32" _
            (ByVal Locale As Long) As Boolean
        Private Declare PtrSafe Function GetUserDefaultLCID Lib "kernel32" () As Long
        Private Declare PtrSafe Function LocaleNameToLCID Lib "kernel32" _
            (ByVal lpName As LongPtr, dwFlags As Long) As Long
    #Else
        Private Declare Function SetThreadLocale Lib "kernel32" (ByVal Locale As Long) As Boolean
        Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
        Private Declare Function LocaleNameToLCID Lib "kernel32" _
           (ByVal lpName As LongPtr, dwFlags As Long) As Long
    #End If

    Private Sub Test()
    Dim userLocale As Long
    'US settings number
    userLocale = GetUserDefaultLCID
    userLocale = 1033
    SetThreadLocale userLocale
    End Sub

    Best,
    Jacek

    Monday, February 18, 2019 10:39 AM