Can't Open PDF - Code included

georget

Registered User.
Local time
Today, 15:27
Joined
Jul 17, 2002
Messages
31
With this code, I can open Word and Excel files, but not PDF. Please let me know what I'm doing wrong. (I tried changing strProg = "C:\Acrobat.lnk" including to a .exe file but nothing happens when I click the Open button)

---------------------------------------------------

Private Sub cmdOpen_Click()

Dim sSourcePath As String
Dim strProg As String
Dim objword As Object
Dim strFile As String
Dim XL As Object

sSourcePath = Me.FilePath

DoCmd.RunCommand acCmdSaveRecord

If fIsFileDIR(sSourcePath) = -1 Then

Select Case ParseFileName(sSourcePath, 3)

Case "xls"

Set XL = CreateObject("Excel.Application")

If IsNull(Me.FilePath) Then
MsgBox "You haven't Attached a File"

Else

With XL.Application
.Visible = True
.workbooks.Open Me.FilePath

End With

Set XL = Nothing

End If

Case "doc"

Set objword = CreateObject("Word.Application")

strFile = Me.FilePath

objword.Visible = True
objword.Documents.Open strFile

'--------------------------------------------------
Case "pdf"
'Open File

strProg = "C:\Acrobat.lnk"

Call Shell(strProg & " " & sSourcePath, vbMaximizedFocus)


Case Else

MsgBox "File type not recognised"

End Select

Else

MsgBox "File cannot be found. Please check the file path. ", vbExclamation

End If

End Sub
 
Are you sure the user has acrobat installed?

I prefer the ShellExecute method I am using to open a file in my
Browse [Find a directory or file] sample.

ShellExecute does not have the problems the Shell() function sometimes has.
 

Users who are viewing this thread

Back
Top Bottom