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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,707
Members
448,981
Latest member
recon11bucks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top