excel - 将区域设置从波兰语更改为美国 windows 10
问题描述
我正在尝试使用此代码:
#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()
'Get the locale identifier for French (Canada)
Dim frCa As Long
frCa = LocaleNameToLCID(StrPtr("fr-CA"), 0)
'Make sure there function succeeded.
If result = 0 Then
'Cache the current locale
Dim userLocale As Long
userLocale = GetUserDefaultLCID
'Switch to French (Canada)
If SetThreadLocale(frCa) Then
'en français
'...
'switch back
SetThreadLocale userLocale
End If
End If
End Sub
来自链接:
我正在寻找类似的解决方案,但上述方法不起作用。我尝试将区域设置更改为美国设置并恢复为波兰区域设置(Windows 默认设置)。
GetUserDefaultLCID = 1045, US = 1033 的波兰设置,但宏运行时没有任何结果。(没有错误,没有变化)。某种 SetThreadLocale 不起作用...
请帮助可能出现的问题,Best,Jacek
当我使用带有我们区域设置的 Windows 但没有工作时,我尝试使用而不是“fr-CA”“pl-PL”并分配给 userLocale = 1045。
目标是让这个宏在 Windows 10 中工作。
解决方案
请注意,稍后If SetThreadLocale(frCa) Then
切换到frCa
1 行(在评论之后),您切换回之前的内容SetThreadLocale userLocale
(如果您阅读了链接的原始线程,它会告诉您这一点)。
所以这种变化只在这两个语句之间发生了很短的时间。
因此,要么将应该在更改后的语言环境上运行的代码放在两者之间:
If SetThreadLocale(frCa) Then
'put your code that should run in polish here
SetThreadLocale userLocale
End If
或者要永久更改语言环境,请使用以下内容而不是上述内容:
SetThreadLocale frCa
推荐阅读
- web - chrome 弃用第三方 cookie 的含义是什么?
- python - 使用 gunicorn 制作 Django Web 应用程序
- java - 尝试在空对象引用上调用虚拟方法“void com.basicprofileapp.dataholder.setUsername(java.lang.String)”
- python - str.split 问题,需要查找字符串中每个分量的长度
- java - 如何在同一类的 Spring Boot 应用程序中启动新线程
- php - 如何检查两个时间戳之间的范围不与其他两个时间戳重叠
- r - R: Multi-type Point Pattern scan.test
- flutter - 如何将数据从 TextForm 保存到列表
- oracle-apex - 创建一个动态每月选项卡,我们可以在其中单击月份,详细信息将使用 Oracle-Apex 显示在下方
- linux - Ubuntu 中的 Terraform 路径问题