I have a Word document with hyperlinks which open a number of PDF files located on a network drive. I would like to be able to open each PDF to a specific page (some hyperlinks point to different pages in the same target PDF file). I tried adding page parameters (e.g. hyperllink Address = pdffilename.pdf#page=5).
This didn't work, so I also tried creating named destinations (pdffilename.pdf#pg5) also with no success. I also tried creating the hyperlink using a macro:
Sub Macro1()
Set SCut = ActiveDocument.Hyperlinks.Add( _
Anchor:=Selection.Range, _
Address:="C:\Documents and
Settings\Administrator\Desktop\pdffilename.pdf", SubAddress:="#page = 2")
End Sub
This macro didn't work as well. After some online research I found page parameters only work when the PDF documents are located on a web server.
I wrote another VB macro to open the PDF docs to the desired page. Below is my code:
Sub Macro2()
Dim a As String, t1 As String, t2 As String, t3 As String
t1 = """C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe"""
t2 = "/A ""page=5"""
t3 = """C:\Documents and Settings\Administrator\Desktop\pdffilename.pdf"""
a = t1 & t2 & t3
Shell a, vbNormalFocus
End Sub
Macro 2 works fine with Word 2002 and Acrobat 6.0. However, when I test on a system that has Word 2003 and Acrobat 7.1.0 I get an error message "There was an error opening this document. The file cannot be found."
After clicking OK the target PDF file opens, but opens to page 1, not to the desired page 5 in this example.
Also, when I type the statement below in Windows (Start/Run) the document opens to page 5 on both systems.
acrobat.exe /A "page=5=OpenActions" "C:\Documents and Settings\Administrator\Desktop\pdffilename.pdf"
Please let me know if there is an alternative way to create a Word hyperlink that will open a PDF file to a desired page.
Thank you in advance!
As you noted, PDF open parameters function via a fully formed URL or the command line.
The documentation identifies a very small population of command line options.
As Adobe Reader/Acrobat security sand box has become more restrictive with each release
I'd not expect command line choices to expand.
As well, external programmatic manipulation of PDFs acting through Adobe Reader/Acrobat
has always been limited and from PDF version 1.7 forward restrictions have become more not less.
The Acrobat section of Adobe's Developer site has documentation that speaks to use of VB, IAC, etc.
You may want to obtain the SDK documentation for review.
Be well...
Be well...