Use the ShellExecute API as it opens the passed files with their default associated application. Only the file to open's path is required, not the program itself.

VB Code:
  1. Option Explicit
  2.  
  3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
  4. ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  5.  
  6. Private Const SW_SHOWNORMAL As Long = 1
  7. Private Const SW_SHOWMINIMIZED As Long = 2
  8. Private Const SW_SHOWMAXIMIZED As Long = 3
  9.  
  10. Private Const ERROR_FILE_NOT_FOUND As Long = 2&
  11. Private Const ERROR_PATH_NOT_FOUND As Long = 3&
  12. Private Const ERROR_BAD_FORMAT As Long = 11&
  13. Private Const SE_ERR_ACCESSDENIED As Long = 5
  14. Private Const SE_ERR_ASSOCINCOMPLETE As Long = 27
  15. Private Const SE_ERR_DDEBUSY As Long = 30
  16. Private Const SE_ERR_DDEFAIL As Long = 29
  17. Private Const SE_ERR_DDETIMEOUT As Long = 28
  18. Private Const SE_ERR_DLLNOTFOUND As Long = 32
  19. Private Const SE_ERR_FNF As Long = 2
  20. Private Const SE_ERR_NOASSOC As Long = 31
  21. Private Const SE_ERR_OOM As Long = 8
  22. Private Const SE_ERR_PNF As Long = 3
  23. Private Const SE_ERR_SHARE As Long = 26
  24.  
  25. Private Sub Command1_Click()
  26.     On Error GoTo MyError
  27.     Dim lRet As Long
  28.     lRet = ShellExecute(Application.Hwnd, "Open", "C:\MyPath\MyFile.pdf", vbNullstring, "C:\", SW_SHOWNORMAL)
  29.     If lRet <= 32 Then
  30.         Select Case lRet
  31.             Case 0
  32.                 'MsgBox "The operating system is out of memory or resources."
  33.             Case ERROR_FILE_NOT_FOUND
  34.                 'MsgBox "The specified file was not found."
  35.             Case ERROR_PATH_NOT_FOUND
  36.                 'MsgBox "The specified path was not found."
  37.             Case ERROR_BAD_FORMAT
  38.                 'MsgBox "The .EXE file is invalid (non-Win32 .EXE or error in .EXE image)."
  39.             Case SE_ERR_ACCESSDENIED
  40.                 'MsgBox "The operating system denied access to the specified file."
  41.             Case SE_ERR_ASSOCINCOMPLETE
  42.                 'MsgBox "The filename association is incomplete or invalid."
  43.             Case SE_ERR_DDEBUSY
  44.                 'MsgBox "The DDE transaction could not be completed because other DDE transactions were being processed."
  45.             Case SE_ERR_DDEFAIL
  46.                 'MsgBox "The DDE transaction failed."
  47.             Case SE_ERR_DDETIMEOUT
  48.                 'MsgBox "The DDE transaction could not be completed because the request timed out."
  49.             Case SE_ERR_DLLNOTFOUND
  50.                 'MsgBox "The specified dynamic-link library was not found."
  51.             Case SE_ERR_FNF
  52.                 'MsgBox "The specified file was not found."
  53.             Case SE_ERR_NOASSOC
  54.                 'MsgBox "There is no application associated with the given filename extension."
  55.             Case SE_ERR_OOM
  56.                 'MsgBox "There was not enough memory to complete the operation."
  57.             Case SE_ERR_PNF
  58.                 'MsgBox "The specified path was not found."
  59.             Case SE_ERR_SHARE
  60.                 'MsgBox "A sharing violation occurred."
  61.         End Select
  62.     End If
  63.     Exit Sub
  64. MyError:
  65.     MsgBox Err.Number & " - " & Err.Description
  66. End Sub