0

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

7
  • 4
    Who can turn this into 64-Bit code? - you can. Commented Jun 20, 2024 at 8:39
  • 1
    Maybe this sheds some more light on the issue. In this case you need to change Longptr for hwnd and hWndInsertAfter. And you need to add the keyword Ptrsafe. Commented Jun 20, 2024 at 9:45
  • Really helpful with many examples is JKP's article Declaring API functions for 64 bit Office and Mac Office Commented Jun 20, 2024 at 10:02
  • 2
    The original Microsoft link has been retired but I created a gist to hold useful API declarations. Commented Jun 20, 2024 at 15:06
  • 2
    @T.M. I simply saved the file in the same state as I downloaded from Microsoft many years ago. The copyright from Microsoft is at the top of the file so I did not think to mention - I did not write any line of code :) But the documentation is indeed impressive. Commented Jun 20, 2024 at 17:35

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.