• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro Help on the code on 64 Bit systems

Hi All,

I am having excel sheet with macro,when i try to run this it shows an error of "The code in this project must be updated for use of 64 bit systems.Please review and update Declarea statements and then mark them with ptrSafe attribute"

Can anyone any help on the above as i am new to macro.

Attached the excelsheet.

Thanks !
 

Attachments

  • KAS2006 v3.3.zip
    742.4 KB · Views: 12
Hi, Nandakumar!

Here you have an example of how to convert declarations from 32 to 64 bits Excel versions or how to use them both. As I don't have any machine at a hand that runs Excel x64 I'm afraid that I won't be of further help.
Code:
Option Explicit
#If VBA7 Then
    Private Declare PtrSafe Function MarcLBeep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Boolean
#Else
    Private Declare Function MarcLBeep Lib "kernel32" Alias "Beep" (ByVal Frq As Long, ByVal Dur As Long) As Boolean
#End If
Regards!
 
What SirJB7 posted is an example of how to adopt x86(32 bit) API call to x64(64 bit).

Just adding his example won't fix your issue. There's 99 functions/subs used in your sample that makes use of swedll32.dll and each must be changed to be compatible.

Note that in addition to declaring PtrSafe for API calls, you may need to change Long type variable to LongPtr in some instances.

Read through link to understand the process of making API calls compatible for x86/x64.

https://msdn.microsoft.com/en-us/library/office/ee691831(v=office.14).aspx

Edit: For clarity on x86/x64
 
Last edited:
Ahem, this really has nothing to do with writing code. Just replacing text string in code...

Process:
Go into VBA editor and go to Module2 (You can go there directly by clicking on debug, when error message comes up).

Then use CTRL + F to find "Declare Function" string and replace with "Declare PtrSafe Function".

Also do CTRL + F to find "Declare Sub" string and replace with "Declare PtrSafe Sub".

Run the code and test. If result of the code is off... then try CTRL + F and replace "Long" in each of Private declaration with "LongPtr".

Do note, some APIs are not meant to work in 64 bit and above may not work. If that's the case... DLL will likely need to be recompiled in 64 bit (which cannot be done via VBA).
 
Back
Top