PDA

View Full Version : Create hyperlinks to other documents that will stay link when creating pdf files



laboymc
06-03-2014, 10:56 AM
Hi,

I am trying to add a VBA code to a word document that has hyperlinks that opens other documents to specific pages. I am able to do it when they are in the doc form however, when I convert all docs to pdf I loose the hyperlinks. I tried the following VBA code to see if it would open the pdf file to the specific destination (like a specific name/bookmark/or page). I have Adobe Acrobat 9 Pro.

Sub GoToPDFPage()
Dim targetLink As String
Dim targetName As String
Dim pageNumber As String
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 = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader"
RtnCode = Shell(AdobePath & " /a " & Chr(34) & "page=" & iMyPageNumber & "=OpenActions" & Chr(34) & sMyPDFPath, vbNormalFocus)
End Function


I aslo get the Sub GoToPDFPage () hilighted in Yellow.
I get the Compile error variable not defined where I write about the parts=Split(targetName, "page=6")

laboymc
06-04-2014, 04:48 AM
Hi,

I got to have the document open in pdf with the hyperlink using the code below
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="..\Desktop\Roster.pdf"

However, how do I specify a bookmark or a phrase within the document?
I tried to use SubAddress:="Phone" but it it won't go to that bookmark or phrase.




I am trying to add a VBA code to a word document that has hyperlinks that opens other documents to specific pages. I am able to do it when they are in the doc form however, when I convert all docs to pdf I loose the hyperlinks. I tried the following VBA code to see if it would open the pdf file to the specific destination (like a specific name/bookmark/or page). I have Adobe Acrobat 9 Pro.

Sub GoToPDFPage()
Dim targetLink As String
Dim targetName As String
Dim pageNumber As String
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 = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader"
RtnCode = Shell(AdobePath & " /a " & Chr(34) & "page=" & iMyPageNumber & "=OpenActions" & Chr(34) & sMyPDFPath, vbNormalFocus)
End Function


I aslo get the Sub GoToPDFPage () hilighted in Yellow.
I get the Compile error variable not defined where I write about the parts=Split(targetName, "page=6")