If vLen > 5 And InStr(vLen – 4, StrConv(vDocument, vbLowerCase), ".pdf") = 0 Then ' Add ".pdf" at the end of the file name if not specified VDocument = Trim(Replace(Replace(aRow.Cells(2).Range.Text, " ", ""), vbCr, "")) ' Remove weird characters put by Word in the cell for the document name If Selection.Information(wdWithInTable) = True Then VAdobe = "C:Program FilesAdobeReader 11.0ReaderAcroRd32.exe" It is working just fine but will need modifications when a new version of Acrobat Reader will be installed (or if I use it on another computer that doesn't have the same version or path for the Reader program) :
#Thebrain 9 excel file preview code#
I added some validations to handle some possible error and here is the code I ended up with. I use code suggested to me that can be found at :
#Thebrain 9 excel file preview pdf#
pdf extension) and the 3rd one is the page number where the information is located in that pdf file. The first column is a description, the 2nd is the pdf file name (with or without the. My file has a table that contain 3 columns.
I tried changing the preference but still have the same problem. In case you have Adobe Reader, use the function. To sum up, if you have Adobe Professional installed on your computer, use the first macro. SendKeys ("^+N" & PageNumber & "~^" & PageView), TrueĪlthough the above function works, the “sendkeys” method has a severe shortcoming: when the macro runs, the user must not use the keyboard because it is possible to corrupt the function. ThisWorkbook.FollowHyperlink PDFPath, NewWindow:=True 'ActivePresentation.FollowHyperlink PDFPath, NewWindow:=True 'ThisDocument.FollowHyperlink PDFPath, NewWindow:=True 'This line depends on the apllication you are using. 'It can be used with both Adobe Reader & Adobe Professional. 'Sendkeys method is used for simulating keyboard shortcuts. 'Opens a pdf file, at specific page and with specific view. Set PDFDoc = CreateObject("AcroExch.AVDoc")įunction OpenPDFPage(PDFPath As String, PageNumber As Long, PageView As Integer) Set PDFApp = CreateObject("AcroExch.App") 'Initialize Acrobat by creating App object PDFPath = ThisWorkbook.Path & "\" & "PDF Sample.pdf" 'PDFPath = ActivePresentation.Path & "\" & "PDF Sample.pdf" 'PDFPath = ThisDocument.Path & "\" & "PDF Sample.pdf" 'PDFPath = "C:\Program Files\Autodesk\ACADM 2010\Setupen-US\Setup\ResDocsAcad_Mech_2010_UserGuide.pdf" 'Change this to your own complete PDF path 'C:Program FilesAdobeAcrobat xx.0Acrobatacrobat.tlb 'Alternatively you can find it Tools -> References -> Browse and check for the path 9.0 or 10.0) you have installed to your PC. 'on your Acrobat Professional version (i.e. 'Go to Tools -> References -> Adobe Acrobat xx.0 Type Library, where xx depends
'In order to use the macro you must enable the Acrobat library from VBA editor: