1
votes

According to different sources one should be able to hyperlink to a specific page in a PDF-file from other applications by appending the suffix: #page=, for example:

C:\Temp\Examplefile.pdf#page=5

This is not working from Word 2013. I have read that it depends on what application and version installed as PDF-file reader on the client and file extension associations, but I think it is an issue with Word 2013. On the same computer I can successfully hyperlink to a PDF page from an HTML-file by using the following HTML-code and click the link in for example Internet Explorer:

<HTML><BODY><A HREF="C:\Temp\Examplefile.pdf#page=5" TARGET="_TOP"> PDF-File </A></BODY></HTML>

I have tried using Adobe Reader XI and Adobe Acrobat 9 Pro as PDF-file reader, but without success. The PDF-file opens but it shows the first page, not the fifth.

Does anyone know how to successfully hyperlink to a specific page in a PDF-file from Word 2013? I am also open to solutions involving VBA code.

5

5 Answers

1
votes

It seems that “the only way to create a hyperlink in a Word document to a specific page or destination in a PDF is if the PDF file is in a web server and you create the link referring to the PDF URL”, to quote an answer at AcrobatUsers.com. So you would use a link with a URL like http://unicode.org/charts/PDF/U0080.pdf#page=5 (to take an arbitrary working example).

Well, any HTTP server should do, it does not need to be on the web but could be an intranet server, or even local to the computer where the Word document is opened. But the point is that when you link to an http:// address, the link will open in a web browser, which can handle a fragment part like #page=5 at the end of a URL.

2
votes

This problem is one I have wrestled with for years and I did eventually get it to work. I have a collection of old magazines in PDF format and I wanted to create an index in Word with hyperlinks against each index entry, which I could convert to a PDF file, such that clicking on the link against any index entry in the PDF file would open the correct magazine PDF file at the correct page. There are several issues.

  1. Using the hyperlink format 'C:\Temp\Examplefile.pdf#page=5' as above in Word will work when the file is converted to PDF if the PDF file is opened in a web browser, or, if the file is opened directly in Adobe Reader, you have a PDF destination called 'page=#' (where # = the page number) set on every page of your destination PDF file. Normally one would want this second option for the kind of job I had in mind.

  2. I know of few Word to PDF conversion programs which will create the links correctly so that the PDF is opened in Adobe Reader rather than a web browser. LibreOffice 5 does it properly if configured correctly, except that it changes 'page=5' to 'page3D5'. There used to be a program called Jaws PDF under Windows XP which did all conversions correctly, but I believe this is not on the market now. So the best option I know of at the moment is to use LibreOffice to convert from Word files to PDF files and use a hyperlink of the format 'C:\Temp\Examplefile.pdf#page5' to avoid the problem with the equals sign. I haven't tested the latest version of Word.

  3. This leaves the issue of how to create PDF destinations. You can use Adobe Acrobat or Nitro Pro PDF e.g. to this manually, but having to create a PDF destination manually for every page of a document is not a task I would wish on anyone. The way I have done it is to use Adobe Acrobat with a plugin called Auto BookMark (https://www.evermap.com/autobookmark.asp) which allows you to automatically create destinations for every page of a PDF file. Incidentally, there is also a way to use this plugin to edit all hyperlinks so that they will open PDF files at a given page without creating any PDF destinations, but it is rather complex and I have not seen the method documented in any Adobe literature, so I have avoided using it.

  4. Finally, if you are contemplating doing what I did, using absolute addresses on a hyperlink as above may not be very useful. However, I can report that using relative addressing, e.g. something like '..\magazines\1985.pdf#page20' should also work.

I would appreciate any more information anyone else can give on this issue as it has taken a lot of my time over the last eight years or so.

2
votes

I've succesfully teste this short and simple macro, to open a saved PDF file in page 4, would be:

Sub macro_name()
     App_Path = "C:\Program Files\Adobe\Reader 10.0\Reader\AcroRd32.exe"
     File_Path = "C:\Documents\test.pdf"
     Page_Num = 4
     Shell App_Path & " /A Page=" & Page_Num & ""&File_Path,vbMaximizedFocus
End Sub

If code is not working, check the Acrobat reader path,
If Acrobat Reader is opening but not file then add space between " " of Page_Num and File_path.

Credits: Michael Avidan

1
votes

You could use a macros script to help solve this problem, but you would have to assign a shortcut key to run the macros script while the hyperlink is selected.

This link should help: Create hyperlink to a specific PDF page in Microsoft Word for Windows

Edit:If the above link does not work or you are having problems following the steps or macros script from the website, then follow the steps below:

  1. If you can see the Developer tab you can skip step 2, otherwise carry on to step 2

  2. To make the developer tab visible you need to navigate to File > Options > Customize Ribbon

And tick the Developer check box

  1. Navigate to the Developer tab and click on the Macros button

  2. Enter the name of the macros script in the textbox under Macros name: and click on the button Create, the name can be anything you want

  3. A new window should appear, you will need to enter the following code:

The code below goes between Sub [name of script]() (where [name of script] is replaced with the name you gave to the script) and End Sub

Dim targetLink As String
Dim targetName As String
Dim pageNumber As Integer
Dim pathPDF As String
targetName = Selection.Hyperlinks(1).Name
parts = Split(targetName, "page=")
pageNumber = parts(1)
pathPDF = Selection.Hyperlinks(1).Address
Call OpenPagePDF(pathPDF, pageNumber)

The next piece of code goes after End Sub

Public Function OpenPagePDF(sMyPDFPath As String, iMyPageNumber As Integer)
Dim RtnCode, AdobePath As String
AdobePath = "Path to Acrobat Reader"
RtnCode = Shell(AdobePath & " /a " & Chr(34) & "page=" & iMyPageNumber & "=OpenActions" & Chr(34) & " " & Chr(34) & sMyPDFPath & Chr(34), 1)
End Function

The whole code should look like this:

Sub [Name Of Script]()
Dim targetLink As String
Dim targetName As String
Dim pageNumber As Integer
Dim pathPDF As String
targetName = Selection.Hyperlinks(1).Name
parts = Split(targetName, "page=")
pageNumber = parts(1)
pathPDF = Selection.Hyperlinks(1).Address
Call OpenPagePDF(pathPDF, pageNumber)
End Sub

Public Function OpenPagePDF(sMyPDFPath As String, iMyPageNumber As Integer)
Dim RtnCode, AdobePath As String
AdobePath = "Path to Acrobat Reader"
RtnCode = Shell(AdobePath & " /a " & Chr(34) & "page=" & iMyPageNumber & "=OpenActions" & Chr(34) & " " & Chr(34) & sMyPDFPath & Chr(34), 1)
End Function

Note that this will not work straight away because you will need to give the path of Acrobat Reader, this is answered in step 6

  1. To find Acrobat Reader you will need to find the folder "Adobe" (usually found in Program Files or Program Files (x86))

When you find the folder you will need to navigate through to Reader 11.0 > Reader

You should see an executable named something like AcroRd32.exe or AcroRd64.exe

The location of Acrobat Reader is the address found at the top of windows explorer and a \ [Executable Name] at the end of the address, where [Executable Name] is replaced with the name of the executable, an example of the location is C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe

  1. Once you have replaced "Path to Acrobat Reader" with the location of Acrobat Reader, the script should work

  2. Before you run the script you first need to place the cursor onto the hyperlink

  3. There are two ways to run the script, you can either set a shortcut key to run it (this is explained from step 11) or you can manually access the macros script to run it (this is explained in the next step)

  4. To manually run the script click on the Developer tab, click on the Macros button and select your macros script and click Run

  5. To set a shortcut key to run the script navigate to File > Options > Customize Ribbon, and click on the button named Customize next to the text "Keyboard shortcuts"

  6. Use the list under the text "Categories:" to select Macros and use the list to the right to select your script

  7. Click on the textbox under the text "Press new shortcut key:" and type in the key combination that will run the script

  8. Click the button Assign and close the two windows

  9. Now every time you use the shortcut key while the cursor is placed on the hyperlink, it should load up the PDF on the correct page

1
votes

All quotation marks are required.

  1. Open MS PowerPoint file
  2. Select text or graphic used to hyperlink to PDF.
  3. From the main menu, select INSERT then click Action.
  4. In the Action Settings window, on Mouse Click tab, enable Run Program.
  5. Including quotes, type or paste

    • "Path to PDF exe/exe file"/A"page=#OpenActions" "path to PDF/PDF file"

    • "Path to PDF exe/exe file" examples:

    "C:\Program Files (x86)\Adobe\Acrobat 2017\Acrobat\Acrobat.exe" "C:\Program Files (x86)\Adobe\Acrobat Reader 2017\Reader\AcroRd32.exe"

    • "page=#OpenActions" example to open PDF at page 205:

    "page=205OpenActions"

    • "path to PDF/PDF file" example:

    "C:\Users\Richard\Desktop\Big Help.pdf"

Complete example:

"C:\Program Files (x86)\Adobe\Acrobat 2017\Acrobat\Acrobat.exe"/A"page=25OpenActions""C:\Users\Richard\Desktop\Big Help.pdf"

Be aware that if you convert the MS Word or PowerPoint file to PDF, the link does not carry to the PDF conversion.