Tzahi
Tzahi

Reputation: 268

cannot recognize excel-VBA object after upgrade excel version

after upgrade from excel 2010 32 bit to 64 bit, all the object i create in the new version cannot be recognize by other computer withe excel 2010 32 bit, i alrady tried to insert this:

If VBA7 = True Then
 ' 32 Bit API
Private Declare PtrSafe Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPtr
Private Declare PtrSafe Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As LongPtr, lpExitCode As Long) As Long
Else ' 64 bit API
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
End If

and it's not working.

plz help :)

Upvotes: 0

Views: 91

Answers (1)

Rory
Rory

Reputation: 34055

That's not correct conditional compilation. It should look like this:

#If VBA7 Then
    ' 64 Bit API
    Private Declare PtrSafe Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPtr
    Private Declare PtrSafe Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As LongPtr, lpExitCode As Long) As Long
#Else    ' 32 bit API
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
#End If

Upvotes: 1

Related Questions