Solved Open files with Access (1 Viewer)

zelarra821

Registered User.
Local time
Today, 10:14
Joined
Jan 14, 2019
Messages
803
Good Morning. I'm looking for a way to open files that I have saved on my computer from VBA.

I have a form with a subform where I save the name of the file (for example, document.pdf, but it can be with any extension). In the main form I have a button to open the document when selecting the record from the subform.

I've seen this option:

Code:
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
Declare Function GetDesktopWindow Lib "User32" () As Long

Function ActionFile(FileName As String, strOrden As String) As Variant
' función que imprime un documento de cualquier aplicación

Dim RetVal As Long
Dim sError As String
Dim LenMsg As Long

'strOrden ---> Open abre el documento
'strOrden ---> Print manda imprimir el documento

' se manda actuar al documento
RetVal = ShellExecute(GetDesktopWindow(), strOrden, FileName, "", "C:\", 1)

End Function

But I get compilation error the first few lines of the shellexecute (I use Access 2016, 64 bit).

See if you can tell me how I fix that, or if there is a different way to do it.

Thanks a lot.
 

Dreamweaver

Well-known member
Local time
Today, 09:14
Joined
Nov 28, 2005
Messages
2,466
Try using this from @isladogs

 

zelarra821

Registered User.
Local time
Today, 10:14
Joined
Jan 14, 2019
Messages
803
Buah, chaval, funciona flama. Muchas gracias.

Buah, kid, it works flame. Thanks a lot.
 

Users who are viewing this thread

Top Bottom