Search code examples
excelvbawindows64-bit

UPDATE FOR USE ON 64-BIT- VISUAL BASIC


I have this message written:

The code in this project must be updated for use on 64-bit systems. Lease review and update Declare statements and then mark them with the PtrSafe attribute.

What should I do?

Public Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Public Declare Function GetThreadLocale Lib "kernel32" () As Long
'
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public 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
Public Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Long

Solution

  • Just add PtrSafe keyword befor Function. See below. You need to add this keyword for every function.

    Public Declare PtrSafe Function GetUserDefaultLCID Lib "kernel32" () As Long
    

    Also read these two article from microsoft.

    Article 1, Article 2