View Single Post
  #1  
Old 20-04-2014, 16:30
HeauxmBru HeauxmBru is offline
Junior Member
 
Join Date: Jan 2011
Posts: 17
Default using 32-bit macros in 64-bit X6 or X7

Ive searched to see if anyone was having trouble using their 32-bit macros in X6 or X7 64-bit. I didn't find much. I was however having trouble with my old macros and have been searching for a solution.

I found a solution in the Help file in the Macro Editor under the 64-Bit Visual Basic for Applications Overview which basically says that the Declare statements for win32 API calls must be modified as follows:

Code:
Public Declare PtrSafe Function GetCursorPos Lib "user32" (ByRef pos As lpPoint) As Boolean

Private Declare PtrSafe Function CreateEvent Lib "kernel32" Alias "CreateEventA" _
        (ByVal lpEventAttributes As LongPtr, ByVal bManualReset As LongPtr, _
        ByVal bInitialState As LongPtr, ByVal lpName As String) As LongPtr
I tried it in both X6 and X7 64-bit and my old macros now work in 64-bit. Notice the PtrSafe keyword which declares the statement can be used in 64-bit environments and the LongPtr data type alias which keeps the macro backward compatible while usable in 64-bit.

Just thought I would share just in case anyone was have trouble.
Reply With Quote