To be on the safe side I've added Chr(34) (which is "- double quotes) around the file name in case there are spaces in folder names, this causes issues and the Shell will stop at a space so won't find that full destination.
--
Another option is 'ShellExecute', add this to your Form's code:
Option Explicit Option Compare Database
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
Private Const SW_SHOWNORMAL As Long = 1 Private Const SW_SHOWMAXIMIZED As Long = 3
'(in the button click event you have chosen:)
Private Sub Command1_Click()
Dim strPath as String strPath="C:\Path to the PDF document"
ShellExecute 0, "Open", strPath, vbNullString, "C:\", SW_SHOWNORMAL End Sub
Regards Alex
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Microsoft Access 308.