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
      obj.Activate
    Case "pdf"
      ......here is the problem.............
    Case Else
  End Select
End Sub

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.