zelarra821
Registered User.
- Local time
- Today, 11:26
- 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:
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.
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.