Log in

View Full Version : How to hyperlink to a specific page of an PDF file from MS Word 2007 using VB 6.0



yogeshspsoft
03-05-2012, 11:17 AM
Hello All:

From MS word 2007, want to Hyperlink to the specific page of an PDF file but it always opens the first page of the PDF file

Using:
StrLocationFileNm = TxtPDFFile.Text & "#page=5"
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=StrLocationFileNm, SubAddress:="", ScreenTip:="", _
TextToDisplay:="Read More..."

Attached it the code that is not working. If someone can help me with making it work

Code Working Prerequisite: VB 6.0
Open word document. Place your cursor where you want the hyperlink text "Read More..." to appear.
Execute the application, Select "Hyperlink" menu, Select the PDF file and its page number to be hyperlinked.
Then click on "Link" button.
In the word document the link "Read More..." will appear that should open the PDF file at specific location but it open the PDF file at first

page (Page# 1) always

Thank you for your valuable time and help

Thanks,
Yogesh

fumei
03-05-2012, 01:28 PM
This:

"#page=5"

is the SubAddress

That is, in Word, anchors must be read as the SubAddress.

yogeshspsoft
03-05-2012, 10:38 PM
Hello fumei:

Thanks for your reply but it did not work

ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="C:\document.pdf", SubAddress:="page=3", ScreenTip:="", _
TextToDisplay:="Read More..."

The above command adds a Hyperlink in the Word document but it opens page=1 only and not 3.

Is there any way that when we click on the Hyperlink in the word document it open that PDF file in BROWSER instead of Acrobat Reader as when we try pasting the "file:///C:\document.pdf#Page=3" in browser it opens the PDF document at Page=3

Thanks,
Yogesh

yogeshspsoft
03-06-2012, 02:43 AM
i mean:

file:///C:/document.pdf#Page=3

yogeshspsoft
03-06-2012, 02:46 AM
How to create a Hyperlink in MS Word that if clicked on the Hyperlink it opens the C:\1.pdf (page=3) file in Browser? Is there any way to achieve this?:think:

fumei
03-06-2012, 03:06 PM
Subaddress has to be a real anchor, not just simply any given page.