Compile error: The code in this project must be updated for use on 64-bit systems

Jiulan Fan 1 Reputation point
2022-02-17T19:41:39.68+00:00

Hi there,

Hope all is good.

My MS office 2016 was upgraded to x64 (from x32), after that I got the following error message when I open the excel file created before

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

Previously my module code read:

Declare Function XXX Lib "shell32.dll" _
Alias "XXXA" (ByVal PPP As Long, ByVal QQQ As String) As Long

Declare Function YYY Lib "shell32.dll" _
Alias "YYYA" (lMYINFOR As MYINFOR) As Long

I have changed above codes to the following

If Win64 Then

Declare PtrSafe Function XXX Lib "shell32.dll" _

Alias "XXXA" (ByVal PPP As LongPtr, ByVal QQQ As String) As Long

Declare PtrSafe Function YYY Lib "shell32.dll" _
Alias "YYYA" (lMYINFOR As MYINFOR) As Long

Else

Declare Function XXX Lib "shell32.dll" _
Alias "XXXA" (ByVal PPP As Long, ByVal QQQ As String) As Long

Declare Function YYY Lib "shell32.dll" _
Alias "YYYA" (lMYINFOR As MYINFOR) As Long

End If

After I saved the file, the compile error was gone but the file constantly froze.

Can you please show me what else I missed in order to make this file (created in x32) work probably for both x32 and x64 Excel versions?

Many thanks,
July

{count} votes

1 answer

Sort by: Most helpful
  1. Doug Robbins - MVP 716 Reputation points
    2022-02-20T07:37:13.36+00:00

    Do you have the 1. before the first declaration?

    DId you use conditional compiling by prefacing the If, Else and End If with #

    Try #If VBA7 then

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.