excelvba64-bit32-bitdeclare

Excel VBA 32-Bit to 64-Bit


I have a old Excel file with 32-bit code. Who can turn this into 64-Bit code?

Private Declare Function SetWindowPos Lib "user32" ( _
                 ByVal hWnd As Long, _
                 ByVal hWndInsertAfter As Long, _
                 ByVal x As Long, _
                 ByVal y As Long, _
                 ByVal cx As Long, _
                 ByVal cy As Long, _
                 ByVal wFlags As Long) _
                 As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Thanks for your help


Solution

  • In this case it is

    Declare PtrSafe Function SetWindowPos Lib "user32" _
        (ByVal hwnd As LongPtr, _
        ByVal hWndInsertAfter As LongPtr, _
        ByVal x As Long, ByVal y As Long, _
        ByVal cx As Long, _
        ByVal cy As Long, _
        ByVal wFlags As Long) As Long
    
    Declare PtrSafe Function GetSystemMetrics Lib "user32" _
        (ByVal nIndex As Long) As Long
    

    Further reading 1, 2, 3