I want to open a pdf file using a command button on a form. I have no problem launching a Word document using a module and code, see below, but how do I change this to launch pdfs:
Module:
Sub OpenWordDoc(strDocName As String)
End Sub
Dim objApp As Object
'Opens the document
Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open strDocName
End Sub
Then code on command button:
Private Sub cmdOpenWordDoc_Click()
If IsNull(Me.Filepath) Or Me.Filepath = "" Then
MsgBox "Please Ensure There Is A File Path Associated " & _
"For This Document", _
vbInformation, "Action Cancelled"
Exit Sub
Else
If (Dir(Me.Filepath) = "") Then
MsgBox "Document Does Not Exist In The Specified Location", _
vbExclamation, "Action Cancelled"
Exit Sub
Else
'Opens document in Word
Call OpenWordDoc(Me.Filepath)
End If
End If
End Sub
Thanks in advance
Module:
Sub OpenWordDoc(strDocName As String)
End Sub
Dim objApp As Object
'Opens the document
Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open strDocName
End Sub
Then code on command button:
Private Sub cmdOpenWordDoc_Click()
If IsNull(Me.Filepath) Or Me.Filepath = "" Then
MsgBox "Please Ensure There Is A File Path Associated " & _
"For This Document", _
vbInformation, "Action Cancelled"
Exit Sub
Else
If (Dir(Me.Filepath) = "") Then
MsgBox "Document Does Not Exist In The Specified Location", _
vbExclamation, "Action Cancelled"
Exit Sub
Else
'Opens document in Word
Call OpenWordDoc(Me.Filepath)
End If
End If
End Sub
Thanks in advance