We help IT Professionals succeed at work.

Access VBA convert declaration to 64 bit

Murray Brown
Murray Brown asked
on
Hi. I have to update the following Access VBA code to work on a 64 bit machine. What would I convert it to? Thanks

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

Open in new window

Comment
Watch Question

Jim Dettman (EE MVE)President / Owner
Fellow 2019
Most Valuable Expert 2017

Commented:
Murray,

   If you look in your last question, I posted a link to a help file which contains all the common API calls and what they need to be modified to for 64 bit.

Jim.
Test your restores, not your backups...
Expert of the Year 2019
Top Expert 2016
Commented:
I also use this reference: Excel: Excel: Declaring API functions in 64 bit Office
      
#If VBA7 Then
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
        ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
#Else
Private 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
#End If

Open in new window

Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Hi Jim. Thanks but I am still not sure what this code should be converted to
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Thanks very much
Jim Dettman (EE MVE)President / Owner
Fellow 2019
Most Valuable Expert 2017

Commented:
<<Hi Jim. Thanks but I am still not sure what this code should be converted to>>

  You download the help file, lookup the call, and it tells you what it needs to be for 64 bit.

  The other article I pointed you to explains what's required for 64 bit as far as PtrSafe and the new data types.  Also explains the compiler constants, and which of those you should be using when.

 There are few in's and out's to this....what you need to do depends on if you are developing a DB that will be used for both 32 and 64 bit or not.  It's not an entirely straight forward process and you should understand some of the details involved.

Jim.