Compile Error after upgrading form Office 32bit to Office 64bit

thepayne78

New Member
Joined
Aug 27, 2019
Messages
3
Okay here is the issue.
Where I work we updating Oracle SmartView to 64bit but before we do that we have to uninstall MS Office 32 bit and install office 64 bit.
I did that and now when he opens the spreadsheet he gets the following message "though Compile error: The code in this project must be updated for use on 64-bit systems. Please Review and update Declare statements then mark them with the PTRSafe Attribute."
The code is below someone informed me all I should have to do is insert PTRSAFE I between Declare and function.
I was just wanting to make sure that is correct. I apologize if I didn't put the code in correctly.

Thank you in advance for you help.



Code:
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)
Public Declare Function LocalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal uBytes As Long) As Long
Public Declare Function LocalFree Lib "kernel32" (ByVal hMem As Long) As Long
Public Declare Function GetLogicalDriveStrings Lib "kernel32.dll" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long



Public Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
52,202
Office Version
365
Platform
Windows
Resolved the issue this thread can be closed.
We do not close threads. Just replying back to it should be sufficient, though it would be helpful if you could post how you resolved it, in case others come across the same problem and find this thread.
 

thepayne78

New Member
Joined
Aug 27, 2019
Messages
3
We do not close threads. Just replying back to it should be sufficient, though it would be helpful if you could post how you resolved it, in case others come across the same problem and find this thread.
Oh yes sorry about that.
When he opened the excel file he would get the error and the Vba Editor would come up.
So in between Declare and whatever word followed it I inserted PtrSafe as seen below.

Code:
Public Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long)
Public Declare PtrSafe Function LocalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal uBytes As Long) As Long
Public Declare PtrSafe Function LocalFree Lib "kernel32" (ByVal hMem As Long) As Long
Public Declare PtrSafe Function GetLogicalDriveStrings Lib "kernel32.dll" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

and

Public Declare PtrSafe Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Then I saved the file and the user was able to open the file without getting the error message.
Apparently the PtrSafe is inserted into Declare statements to signify the Declare statement explicitly targets 64bits.
 

Watch MrExcel Video

Forum statistics

Threads
1,090,424
Messages
5,414,373
Members
403,526
Latest member
swedeness50

This Week's Hot Topics

Top