Launch Adobe pdf file from form

AllyBally

New Member
Joined
Mar 6, 2006
Messages
39
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 Adobe Acrobat 7.0 pdfs:

Code:
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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try This:

Code:
Private Declare Function ShellExecuteA Lib "shell32.dll" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Function openpdf(strpdfFile As String)
 ShellExecuteA Application.hWndAccessApp, "open", strpdfFile, vbNullString, vbNullString, 1
End Function

openpdf("C:\Documents and Settings\X\Desktop\order.pdf")

HTH,
CT
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,696
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top