I am developping an user interface in VBA to manage an MS access database. I am confronted with a task that consists to open any document file store on a computer using a VBA command. I can do that that for any MS office document but failing with other document file like pdf, or image. Can anyone have some tips?
Thanks in advance
Below is the sub that is working with word document.

Private Sub OpenFile_DblClick(FileName as string)
  Dim fExt As String
  fExt = LCase(Mid(fName, InStrRev(fName, ".") + 1))  'To extrat the file extension
  Select Case fExt
    Case "doc"
      Dim obj As Word.Application
      Set obj = CreateObject("word.application")
      obj.Documents.Open FileName
      obj.Visible = True
      obj.WindowState = wdWindowStateNormal
    Case "pdf"
      ......here is the problem.............
    Case Else
  End Select
End Sub

Edited by Nick Evan: Added CODE-tags

6 Years
Discussion Span
Last Post by AndreRet

Use your friends (yahoo, google, ask, answers, bing) and search for ShellExecute API or ShellExecuteEx API with the key word vb6 to get some code that will work for you in VBA...

Good Luck


for Pdf, set a reference to Adobe Reader Type Libraries, use the same object code as for word, and that should open the pdf file. For other applications, do the same.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.