JoaMika
JoaMika

Reputation: 1827

VBA Code 64-bit Systems

I am getting an error that my code needs to be updated for Office 64-bit systems. I can't understand what changes need to be made as this works fine on Office 32-bit.

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

Upvotes: 0

Views: 1829

Answers (2)

JoaMika
JoaMika

Reputation: 1827

I've read the guidelines provided. I think declaring PtrSafe like this should do it?

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

Upvotes: 2

Fumu 7
Fumu 7

Reputation: 1091

Windows API functions in 32-bit system and in 64-bit function are different.

Try following code instead.

#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

Win64 is decleared if the office system is compiled in 64-bit mode, otherwise it is not decleared.

By using Win64 to determine the system is 64-bit or 32-bit, you can use suitable function for your office system.

Upvotes: -1

Related Questions