- Dec 13, 2006
I'm trying to open a pdf file from within excel vba. I have tried using the followhyperlink method but adobe acrobat opens very briefly then immediately closesSo then I tried to create an instance of acrobat by setting a reference to the acrobat object but I can't get this to work either!
The code I'm using isAny ideas what could be wrong with either approach?
Sub OpenPDF() 'Dim pdf As String On Error Resume Next 'pdf file to open pdf = "K:\PDF\mypdf.pdf" 'open the pdf file ActiveWorkbook.FollowHyperlink pdf End Sub
The code I'm using is
Sub OpenPDF() Dim pdf As AcroPDDoc Dim strPDF As String Set pdf = CreateObject("AcroExch.PDDoc") 'pdf file to open strPDF = "K:\PDF\mypdf.pdf" 'open the pdf file pdf.Open strPDF End Sub