![]() |
go to a page in a pdf file
I have read some of the posts about how to open up a pdf file (shell command). Does anyone know how to open a pdf file and go to a specified page in the pdf file? Thanks |
go to a page in a pdf file
Looks like you might be able to do it from a hyperlink: 'Link from an HTML page to a specific page in PDF file (Acrobat 7.x, Acrobat 3D)' (http://kb2.adobe.com/cps/317/317300.html) although Excel may not support that kind of hyperlink - if not you might need to put an IE control on an Excel userform and work through that. Alternately, 'PDF and VBA Code Help - Access World Forums' (http://www.access-programmers.co.uk/...d.php?t=100665) presents code that (reportedly works) but you will probably need to download and add to your project a reference to an OLE from Adobe (I don't know where to download it - try a Google or Bing search on Adobe OLE and see what comes up). Good luck on this :Bgr and report back here when you get it working! -- jamescox ------------------------------------------------------------------------ jamescox's Profile: http://www.thecodecage.com/forumz/member.php?userid=449 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=109374 |
go to a page in a pdf file
I cannot get the hyperlink to work - i've tried:
=HYPERLINK("\\server.com\file.pdf#page=2") =HYPERLINK("\\server.com\file.pdf#nameddest=bookma rkname") =HYPERLINK("F:\server.com\file.pdf#page=2") =HYPERLINK("F:\server.com\file.pdf#nameddest=bookm arkname") (Is a bookmark the same as a named destination?) But if I type in \\server.com\file.pdf#page=2 in IE it works fine. Maybe the IE control on an excel userform would work. Could you explain a little more about that to get me in the right direction? Thanks "jamescox" wrote: Looks like you might be able to do it from a hyperlink: 'Link from an HTML page to a specific page in PDF file (Acrobat 7.x, Acrobat 3D)' (http://kb2.adobe.com/cps/317/317300.html) although Excel may not support that kind of hyperlink - if not you might need to put an IE control on an Excel userform and work through that. Alternately, 'PDF and VBA Code Help - Access World Forums' (http://www.access-programmers.co.uk/...d.php?t=100665) presents code that (reportedly works) but you will probably need to download and add to your project a reference to an OLE from Adobe (I don't know where to download it - try a Google or Bing search on Adobe OLE and see what comes up). Good luck on this :Bgr and report back here when you get it working! -- jamescox ------------------------------------------------------------------------ jamescox's Profile: http://www.thecodecage.com/forumz/member.php?userid=449 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=109374 |
go to a page in a pdf file
Correction on the last post - For the last two hyperlinks, I meant to put
(without server.com): =HYPERLINK("F:\file.pdf#page=2") =HYPERLINK("F:\file.pdf#nameddest=bookmarkname") (these do not work) "Asbest" wrote: I cannot get the hyperlink to work - i've tried: =HYPERLINK("\\server.com\file.pdf#page=2") =HYPERLINK("\\server.com\file.pdf#nameddest=bookma rkname") =HYPERLINK("F:\server.com\file.pdf#page=2") =HYPERLINK("F:\server.com\file.pdf#nameddest=bookm arkname") (Is a bookmark the same as a named destination?) But if I type in \\server.com\file.pdf#page=2 in IE it works fine. Maybe the IE control on an excel userform would work. Could you explain a little more about that to get me in the right direction? Thanks "jamescox" wrote: Looks like you might be able to do it from a hyperlink: 'Link from an HTML page to a specific page in PDF file (Acrobat 7.x, Acrobat 3D)' (http://kb2.adobe.com/cps/317/317300.html) although Excel may not support that kind of hyperlink - if not you might need to put an IE control on an Excel userform and work through that. Alternately, 'PDF and VBA Code Help - Access World Forums' (http://www.access-programmers.co.uk/...d.php?t=100665) presents code that (reportedly works) but you will probably need to download and add to your project a reference to an OLE from Adobe (I don't know where to download it - try a Google or Bing search on Adobe OLE and see what comes up). Good luck on this :Bgr and report back here when you get it working! -- jamescox ------------------------------------------------------------------------ jamescox's Profile: http://www.thecodecage.com/forumz/member.php?userid=449 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=109374 |
go to a page in a pdf file
Assuming you are working out of Excel, this will do it: Public Sub PDFPageViaIE(strUrl as String) Dim ie As InternetExplorer Set ie = New InternetExplorer On Error Resume Next ie.navigate strURL Do DoEvents Loop Until ie.readyState = READYSTATE_COMPLETE Set ie = Nothing End Sub where strURL is in the form of F:\server.com\file.pdf#page=2 or \\server.com\file.pdf#page=2 or even http://www.irs.gov/pub/irs-pdf/fw4.pdf#page=2 (my test file :Bgr ) Of course, this does open it in an Internet Explorer browser window - and it may be a new tab in an existing IE window if you have one already open. The .Navigate method may accept parameters that force it to use a new window - you can look for that, if you feel you need that functionality. -- jamescox ------------------------------------------------------------------------ jamescox's Profile: http://www.thecodecage.com/forumz/member.php?userid=449 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=109374 |
go to a page in a pdf file
Thanks, it works great!
Is there a way to navigate to different pages without having to create a new object every time? I tried to create an object variable that I can reuse with another procedure but it does not work for the second procedure. Here is my code: Static Sub PDFPageViaIE() Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") Const strURL As String = "F:\server.com\file.pdf#page=2" ie.navigate strURL ie.Visible = True End Sub Static Sub PDFPageViaIESecondPage() Const strURL2 As String = "F:\server.com\file.pdf#page=5" ie.navigate strURL2 ie.Visible = True End Sub "jamescox" wrote: Assuming you are working out of Excel, this will do it: Public Sub PDFPageViaIE(strUrl as String) Dim ie As InternetExplorer Set ie = New InternetExplorer On Error Resume Next ie.navigate strURL Do DoEvents Loop Until ie.readyState = READYSTATE_COMPLETE Set ie = Nothing End Sub where strURL is in the form of F:\server.com\file.pdf#page=2 or \\server.com\file.pdf#page=2 or even http://www.irs.gov/pub/irs-pdf/fw4.pdf#page=2 (my test file :Bgr ) Of course, this does open it in an Internet Explorer browser window - and it may be a new tab in an existing IE window if you have one already open. The .Navigate method may accept parameters that force it to use a new window - you can look for that, if you feel you need that functionality. -- jamescox ------------------------------------------------------------------------ jamescox's Profile: http://www.thecodecage.com/forumz/member.php?userid=449 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=109374 |
go to a page in a pdf file
To use an object created in one sub in another sub, you have to move the Dim statement out of the first sub and put it at the top of a code module (not a form module or a worksheet or the ThisWorkbook code module). Your code would then begin to look like: Public ie As InternetExplorer Static Sub PDFPageViaIE() Set ie = CreateObject("InternetExplorer.Application") Const strURL As String = "F:\server.com\file.pdf#page=2" ie.navigate strURL ie.Visible = True End Sub Static Sub PDFPageViaIESecondPage() Const strURL2 As String = "F:\server.com\file.pdf#page=5" ie.navigate strURL2 ie.Visible = True End Sub As a general rule, avoid Dim X As Object, especially where you know what sort of object X is going to be. Hope this helps. -- jamescox ------------------------------------------------------------------------ jamescox's Profile: http://www.thecodecage.com/forumz/member.php?userid=449 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=109374 |
All times are GMT +1. The time now is 10:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com