Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Linking to a Specific Page in a PDF File

Gary wants to link from an Excel worksheet to a specific page in a PDF file. He can get Excel to link to the PDF but it starts on the first page of the PDF, not the page he wants. Gary believes that Excel is ignoring the PDF command that tells it the page he wants. As an example, he can use the formula =HYPERLINK("E:\\test\gary.pdf#5") and Excel ignores the #5 part and opens to the first page of the PDF.

This does, indeed, seem to be the case, Gary. The HYPERLINK worksheet function seems to ignore the page specification for some strange reason. There also doesn't seem to be a way around this problem with the function.

Fortunately, you can use a macro to do the opening, if you desire. The following macro relies upon Internet Explorer to open the PDF and display the proper page:

Sub OpenPDFpage()
    Dim myLink As String
    Dim TargetPage As Double
    Dim objIE As New InternetExplorer

    myLink = "path/filename.pdf"
    TargetPage = 7   'Page number to be shown

    With objIE
        .Navigate myLink & "#page=" & TargetPage
        .Visible = True
    End With
End Sub

The code could also be rather easily changed to a function to which you can pass the desired path and target page.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3350) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Related Tips:

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

Derek    28 Nov 2016, 10:44
I'm desperately trying to get this to work using Excel 2016 with no luck. With the code as is (substituting my local file path and name) I get a compile error at 'Dim objIE As New InternetExplorer' saying 'User defined type not defined'. I would dearly love this to work as a function so I could pass the page parameter. Any thoughts on getting it working. Many thanks.
Petr    24 May 2016, 11:31
Hi Allen
No success for Excel 2010. PDF-file is ever open on the page 1. Also another parameters as zoom etc. are ignored.
A relatively positive message is, that in Excel 2013 it works completely OK.
Is there something wrong with my Excel 2010?
Petr
Ryan    14 Jan 2016, 21:31
How can I do this is Excel

1. How to create a hyperlink from a scanned pdf file saved in my local folder

Ex.
Invoice: Amount: Scanned Invoice Pdf:
123 $2,000 SIPDF12345
124 $2,000 SIPDF12346

Will there be a macro wherein it will automatically open the pdf file from scanned invoice pdf folder saved in local folder(e.g.,SIPDF12345 & SIPDF12346).
Lynn    04 Aug 2015, 10:50
How do I convert the code in the original posting to a function?

I need to open multiple PDF files to different page numbers in the same workbook and I would like to create a function. I need them to open from my local drive and would like them to open using a function so that other users of the function do not need to alter the source code in excel.

I have it working right now where it opens in Windows Explorer, but that does not allow the users to edit the PDF document once open.

Here is my function that works for Windows Explorer:

=HYPERLINK(GoToPDFpage("C:\Users\Desktop\Binder1.pdf",3),"LINK")

Here is the source code behind it: (How do I change it so that it opens the Adobe Reader or Acrobat instead of IE?)

Function GoToPDFpage(Fname As String, pg As Integer)
    
Set IE = CreateObject("InternetExplorer.Application")

With app
.Navigate Fname & "#page=" & pg
.Visible = True
End With
End Function


Please help! Thanks,
Slavo    04 May 2015, 04:06
Hi there, thank you all for valuable tips. In fact, the hyperlink function works well for me and I can open the pdf file at the desired page using the =hyperlink("E:\testgary.pdf#page=5") line. However, is there a way to take a number, say ‘5’, automatically from another column and implement it in the formula? This would let me to avoid editing the hyperlinks once in a cell.
Thanks in advance!
kuei    12 Feb 2015, 20:54
How can I hyperlink to a certain page of a PDF document if I have embedded that PDF within my Excel spreadsheet?
GDFR    19 Dec 2014, 17:36
Attempted to replicate Richard Chapman experiment, but could not get the link to go to a specific page. It always opens on page 1 using

=hyperlink("E:\testgary.pdf#page=5")

Using Excel 2010.
Robert    06 Nov 2014, 05:34
Hey guys,
One of the ways I did this as I was hyperlinking an excel doc to a specific page in a PDF. I save the PDF on the page that I wanted. Then I hyperlinked it. As long as the PDF doesn't get saved again on a different page or you don't need multiple specific pages then this may be good for you. Good luck
KB    07 Oct 2014, 13:00
There is a way i figured out where you can use the #page=[page#]. without vb! the catch is that you have to have the excel file on the same drive as the file you are linking it to.

so.

in the command for the cell =(hyperlink"","")

use
\\[drive]\[file path]
insetead of
drive:\\[filepath]

this is the only things that has worked for me
boojiboy16    28 Sep 2014, 20:00
let excel write and run a batch file to open the pdf. Edit the file paths and if you are bothered about leaving the bat file move the kill command to a workbook close event.

Sub WriteAndRunBatFile()
    Dim retVal
    strFilePath = "c:\folder\pdf.bat"
    pg = 2
    Open strFilePath For Output As #1
    Print #1, "Start /Max /w " & Chr(34) & "Current E-book" & Chr(34) & " " & Chr(34) & "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" & Chr(34) & " /a " & Chr(34) & "page=" & pg & Chr(34) & " " & Chr(34) & "H:\Documents\RPG\Dragonlance\New folder\Sample File.pdf" & Chr(34) & ""
    Close #1
    retVal = Shell(strFilePath)
    'Kill strFilePath
End Sub
Richard Plant    21 Sep 2014, 22:39
SORRY, but Excel 2010 using the HYPERLINK() and specifying the page number using the #page=5 DOES NOT WORK. I have tried this numerous different ways with different files and it just does NOT work. DOES anyone have a way to Hyperlink() to a PDF file and go to a SPECIFIC PAGE?
Mohammad    21 Aug 2014, 07:40
I have a Excel that I am trying to add hyperlinks to go to a specific page on a pdf file. How do I do that with vba macro?
Michael (Micky) Avidan    16 Jul 2014, 07:12
To my opinion, the shorest and simplest macro, to open a saved PDF file in page 4, will be:
------------------
Sub Micky()
     App_Path = "C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe"
     File_Path = "D:\TEST\444.pdf"
     Page_Num = 4
     Shell App_Path & " /A Page=" & Page_Num & " " & File_Path, vbMaximizedFocus
End Sub
---------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL
M B    15 Jul 2014, 13:15
To echo AW's comment, the HYPERLINK("file.pdf#page=3","clicktoseePg3") does not open to page 3 of the named PDF document, it brings up only page 1 of the same document.
Magnus    15 Jul 2014, 03:17
The above method does not work if you print out as PDF using the Adobe Acrobat driver. Nothing happens if you click on the hyperlink in the PDF, because Adobe can not interpret weblinks made using the "=hyperlink()" function.

A simple work-around is to mark the whole spread sheet in MS Excel, copy, and in Adobe select "Create PDF from clipbook". Then the hyperlink function works.
Maria    28 May 2014, 08:13
I have a word doc that I am trying to add hyperlinks to go to a specific page on a pdf file. How do I do that with vba macro?
numb3rs666    04 Dec 2013, 11:04
Excel Office 2010 on Win 7 64 bit
Hyperlink to a specific pdf page:
http://Area%20Riservata1/J.ch%20-%20Cent.pdf?#page=851

The above Hyperlink work on office 2003 WinXP with office 2010 it don't work because of: in browser IE 10-11 the link is .......Cent.pdf%20-%20page=851.
20%-20% instead of #
Please could you help me? I don't want to use a macro but a HL in a cell.

thanks
Grant Livet    31 Oct 2013, 10:54
Thanks again Richard. However, I tried it and it changes the # sign to a %20-%20 in the web browser (Google Chrome) and then says file is not found. If I change the url manually in my browser back to the # sign it works. I also tried this for a pdf residing on my dropbox account, and it pulls up the file, but then does not search it. Does this parameter not work for a https url?
Richard Chapman    30 Oct 2013, 10:21
Grant, the HYPERLINK function's open parameters don't work on PDF files stored on your computer but it can work for PDF files that can be found using a URL (http://) file location.

This works for me (using Excel 2010):

In cell A1, enter the URL + the first part of search open parameter, for example: http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf#search=

In cell A2, enter the desired search term(s), for example:
wordList

In cell A3, enter the hyperlink function pointing to cells A1 & A2, for example:
=HYPERLINK(A1&A2,"link to PDF with a search open parameter")

Change the search term in cell A2 to open the PDF file highlighting different search term(s).
Grant Livet    28 Oct 2013, 10:21
Thanks Richard. Unfortunately, it appears the pdf search does not work, as it seems to ignore my search parameters and continue opening the file to the first page. I'm linking to a local pdf if that makes a difference. Also, is is possible to use a cell reference to search for the value in an adjacent cell instead of having to type the search item in manually. Any ideas would be appreciated. Thank you.
Richard Chapman    25 Oct 2013, 09:30
You can put the URL directly in a cell in Excel (no macro required). Click Insert>Hyperlink and put the URL in the Address field: [ http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf#search="PersonsLastName" ]. In the Text to display field, enter whatever text is desired. For example: Click HERE to open the PDF document to see more information about this Person's Name.

NOTE: You will need to find a search term that appears only once in the PDF document for it to open on the specific page. If the "PresonsLastName" appears more than once in the PDF document, it will open on the first page with the search navigation window pre-populated with the various locations the PersonsLastName appears in the document. Spaces in the #search parameter setting means OR for the search conditions.
Richard Chapman    25 Oct 2013, 09:01
Adobe defines parameters that allow you to open a PDF document with a command or URL that specifies exactly what to display (a named destination or specific page), and how to display it (using such characteristics as a specific view, scrollbars, bookmarks, annotations, or highlighting). See details at http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf#search="page=pagenum"
Grant Livet    24 Oct 2013, 14:29
Any ideas on how this could be modified to search for the value of the cell in the pdf and go to that page. I.E. the cell has a person's name in it, and by clicking on the cell, it will hyperlink to the pdf and search for the name in the pdf and go to that page?

Thanks,
Brian Hershman    21 Oct 2013, 14:19
If you:
(1) need a macro (e.g. to add button to QAT or Ribbon)
AND
(2) want to open only one fixed file
AND
(3) do not need to open a specific page

the following very simple VBA macro works perfectly:

Sub Array_Formula_Help()
  ThisWorkbook.FollowHyperlink _
  "C:\Users\DELL\Documents\Excel\Amazing Array Formulas tips\ETAF3E.pdf"
End Sub
Giovani    11 Sep 2013, 13:49
Thanks PL.ER.RAJAN, It works, perfect for me :D
Grant Livet    17 Jul 2013, 12:49
Any ideas on how this could be modified to search for the value of the cell in the pdf and go to that page. I.E. the cell has a person's name in it, and by clicking on the cell, it will hyperlink to the pdf and search for the name in the pdf and go to that page?

Thanks,
PL.ER.RAJAN    25 Jan 2013, 07:42
With some modification it worked as below:

create a function as below:

Function OpenPDFpage(myLink As String, TargetPage As Double)
    Set objIE = CreateObject("InternetExplorer.Application")
    With objIE
        .Navigate myLink & "#page=" & TargetPage
        .Visible = True
    End With
End Function

In excel enter a formula
in column C
=IF(D9="Y",OpenPDFpage(E9,F9),"-")

D, Y or N
E, Full path and file name
F, Page no


thanks,
GH    17 Jan 2013, 11:44
I too was trying to link to an internal PDF page and tried the HYPERLINK function. It does not link into an internal page. And I am using v2010.

However, if the Hyperlink dialog box [not the =HYPERLINK() function] is used to create the link, it DOES work.
AW    15 Jan 2013, 17:24
Using #page= does not work if the file is stored locally, at least it's not working for me. From what I've read online using #page= only works if you're hyperlinking to a URL
Richard Chapman    15 Jan 2013, 13:51
In v2010, using #page=5 as the target in the hyperlink formula works without a macro.

=HYPERLINK("E:\testgary.pdf#page=5")
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.