Late to the party but I stumbled across this and wanted to comment a few tweaks to Colin's revisions to the Dev Ashish fHandleFile() necessary to run it on 64-bit Access.
First, revise the apiShellExecute #VBA7 declaration to:
Code:
Declare PtrSafe Function apiShellExecute 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
This requires altering the declaration of the variable holding the ShellExecuteA() return value:
Code:
#If VBA7 Then
Dim lngReturn As LongPtr
#Else
Dim lngReturn As Long
#End If
Also, the Window constants got changed from the original. The correct ones are:
Code:
Public Const WIN_NORMAL = 1 'Open Normal
Public Const WIN_MAX = 3 'Open Maximized
Public Const WIN_MIN = 2 'Open Minimized
Unrelated to how it works, the function doesn't exploit these, passes identical values to both ShellExecuteA() and Shell(), and those functions' constants are identical in this range, so my implementation skips those declarations entirely. This necessitates a slight revision of the Shell() call:
Code:
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " & sFile, lShowHow)
I also altered the signature to make the lShowHow parameter optional and default it to 1 (normal), to simplify the call in most instances:
Code:
Function fHandleFile(sFile As String, Optional lShowHow As Long = 1) As Variant
I also tweaked the construction of the return value to yield something CBool() could consume:
Code:
fHandleFile = lReturn & IIf((LenB(sReturn) = 0), Null, ", " & sReturn)
HTH