Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking to PDF

Status
Not open for further replies.

imarg

Technical User
Jun 5, 2006
18
CA
Hi everyone,

I have been trying to come up with a way to create a link from word to a specific page inside a pdf document. I know that for a document thats on a web server you can just append "#page=n" to the end of the address, but I need to do this with locally stored documents. I know this is possible to do using DDE but I don't know how to properly set this up, and google has not provided me with anything concrete.

Help would be much appreciated.

Thanks
 
Hi,

I don't like your chances. The "#page=n" appendix,I strongly suggest, will only work on Word documents.

As you suggest you can create a link to a pdf from Word but it just opens the document according to the file associations established on your pc. It is unlikely that the Acrobat Reader will understand the parameters in Word to locate a specific page.

To get to a specfic page in the Acrobat reader you must use Ctrl N and enter the page no. If there were bookmarks in the pdf when it was created you could use those in the Navigation window on the left side of the Acrobat Reader window.

Good Luck!

Peter Moran
 
Hi again,

The "#page=n" appendix would work if the pdf document I was trying to link to was on a internet/intranet server, but due to confidentiality reasons it is being kept on the local LAN, so that command can't work.

The document is extremely long, and only a few sections need to be linked to, so if anyone knows how to link to a specific page programatically (i.e. DDE, OLE) please let me know.

Thanks.
 
imarg is correct, "#page=n" will open the given pdf to the specified page.


will open Reader to Page 4.

However, I am not understanding the question really. You state
create a link from word to a specific page inside a pdf document.
What do you mean precisely by this?

A link that will open it in Reader at page X? What is this link supposed to be like in Word? A hyperlink?

Assuming it is a hyperlink, even changing the Hyperlink Address to be, for example:

c:\gerry\Designer.pdf#page=6 - does not work

Changing it to:

file:///c:/gerry/Designer.pdf#page=6 - does not work

Although of course passing that to an instance of IE will indeed open reader to Page 6.

Using VBA to add a SubAddress, then trying to fire it via code, as in:
Code:
With Selection.Hyperlinks(1)
   .SubAdress = "#Page=6"
   .Follow
End With
still just opens the pdf in Reader on Page 1. This is because in Office "SubAddress" only refers to Office locations. The named location can be a bookmark in a Microsoft Word document, a named cell or cell reference in a Microsoft Excel worksheet, a named object in a Microsoft Access database, or a slide number in a Microsoft PowerPoint presentation. But NOT a parameter passed to Reader.

still grasping at straws...I don't use a pdf maker, or have a converter in Word. I try to open a PDF with Word, and it is garbage. However, if you DO, then you may be able to use a FileConverter object, such as:
Code:
Documents.Open FileName:="c:/gerry/Designer.pdf#page=6", _
    Format:=FileConverters("AdobeAcrobatReader").OpenFormat
This is making a HUGE assumption - that there is such a converter.

Other than that, I am stumped. I can not get Word to pass that #page=n" paramter via a hyperlink address.

Gerry
My paintings and sculpture
 
Thanks Gerry,

This code here is supposed to be able to do the trick

Code:
anobject.LinkExecute[DocGoTo"c:/imarg/document.pdf",5)]


This is supposed to work but when the VB code runs, it says that an object is required, and I can't figure out what kind of object its asking for.

 
Hi imarg,

I am in a positive mood today! Sorry about my previous comments. Here are the results of my thinking and experiments:

I created a link in a Word document via IE as such:

Code:
file:///C:/Program%20Files/iPod/iPod%20Updater%202005-09-06/iPod%20User%20Guide.pdf#page=21

This works for me.

I used IE and File Open and browsed to the file and then when it opened copied the link, and finally pasted the link into the word doc as a hyperlink with the page no added. Using IE the "page" bit does not get updated as you scroll thru the pdf, so I think you will have to add the page bit as you paste the link.

Good Luck!

Peter Moran
 
Thanks Peter,

Your suggestion did not work directly in word, as word didn't know it had to open the file in internet explorer and still just opened it in reader.

What I did was create a vbs script that does do the trick using the code below.

Code:
Dim shell
Dim iepath
Dim location
Dim Page

location = "[COLOR=red]location of file you are linking to[/color]"
Page="[COLOR=red]Page # you want to open the document to[/color]"
call Hyperlink(location,page)



Sub Hyperlink(location,page)

Page="#Page="&Page
location = Replace(location," ","%20")
location = Replace(location,"\\","")

set shell = createobject("wscript.shell")

iepath = "c:\program files\internet explorer\"

Dim path
path="iexplore file://"&location&Page

ie = Shell.run(path, 1)

END Sub

Thanks again Peter, I would not have thought of getting that done through IE.

Note: The above script is formatted to work with files located in a LAN folder, it would have to be slightly changed for opening a file on a letter drive.

Cheers,

imarg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top