2014-10-05 106 views
0

我得到一个错误,我的代码需要更新Office 64位系统。我无法理解需要进行哪些更改,因为这在Office 32位上可以正常工作。VBA代码64位系统

Private Declare Function GetTimeZoneInformationAny Lib "kernel32" Alias _ 
    "GetTimeZoneInformation" (buffer As Any) As Long 
+1

错误说的是什么? – SLaks 2014-10-05 02:18:26

+0

请参阅[MSDN](http://msdn.microsoft.com/en-us/library/office/ee691831%28v=office.14%29.aspx#odc_office2010_Compatibility32bit64bit_Comparing32BitSystemsto64BitSystems)和[JKP](http://www.jkp -ads.com/articles/apideclarations.asp) – 2014-10-05 03:18:38

+0

好的谢谢,但我很困惑。我应该使用VBA7还是Win64属性? – 2014-10-05 17:05:03

回答

2

我读过了提供的指导方针。我认为像这样宣布PtrSafe应该这样做?

Private Declare PtrSafe Function GetTimeZoneInformationAny Lib "kernel32" Alias _ 
    "GetTimeZoneInformation" (buffer As Any) As Long 
-1

32位系统和64位函数中的Windows API函数是不同的。

请尝试下面的代码。

#If Win64 Then 
    Private Declare Function GetTimeZoneInformationAny64 Lib "kernel32" Alias _ 
     "GetTimeZoneInformation" (buffer As Any) As Long 
#Else 
    Private Declare Function GetTimeZoneInformationAny Lib "kernel32" Alias _ 
     "GetTimeZoneInformation" (buffer As Any) As Long 
#End If 

如果办公系统是以64位模式编译的话,Win64将会被删除,否则它不会被删除。

通过使用Win64来确定系统是64位还是32位,您可以使用适合您的办公系统的功能。