Open pdf file selected from excel

D

damorrison

I am using a code to select a folder, and then show the pdf files
Sub SelectPdfFile()
Dim fn As Variant
Dim i As String
i = InputBox("Enter Job Number", , "Job Number")

P = "C:\" & i & "\"
ChDrive P
ChDir P


fn = Application.GetOpenFilename("PDF Files,*.pdf", _
1, "Select Truss Picture", ,
False)
If TypeName(fn) = "Boolean" Then Exit Sub ' no selection
Debug.Print "Selected file: " & fn
Workbooks.Open fn
End Sub
.............
Is there a way to open the selected pdf file from this location with
acrobat?
Or would it be better to insert the pdf as an object
something like this
------------
Sub SelectPdfFile()
Dim fn As Variant
Dim i As String
Dim p As String
i = InputBox("Enter Job Number", , "Job Number")

p = "C:\" & i & "\"
ChDrive p
ChDir p


fn = Application.GetOpenFilename("PDF Files,*.pdf", _
1, "Select Truss Picture", ,
False)
If TypeName(fn) = "Boolean" Then Exit Sub ' no selection
Debug.Print "Selected file: " & fn
ActiveSheet.OLEObjects.Add(Filename:=p & fn & ".pdf", _
Link:=False, DisplayAsIcon:=False).Select
End Sub
 
R

ruic

' Specifying 1 as the second argument opens the application in
' normal size and gives it the focus.

Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator
 
D

damorrison

' Specifying 1 as the second argument opens the application in
' normal size and gives it the focus.

Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator
Very interesting,
Acrobat opens but the selected file does not, here is the new code:
Sub SelectPdfFile()
Dim fn As Variant
Dim i As String
Dim p As String
Dim RetVal
i = InputBox("Enter Job Number", , "Job Number")

p = "C:\" & i & "\"
ChDrive p
ChDir p


fn = Application.GetOpenFilename("PDF Files,*.pdf", _
1, "Select Truss Picture", ,
False)
If TypeName(fn) = "Boolean" Then Exit Sub ' no selection
Debug.Print "Selected file: " & fn
RetVal = Shell("C:\Program Files\Adobe\Reader 8.0\Reader
\AcroRd32.exe", 1) & fn
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top