Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Business Applications Business Applications
Search Search
Search for:
Tech Support Guy > > >

Hyperlink to specific .pdf page from Excel


(!)

laguy83's Avatar
laguy83 laguy83 is offline
Member with 32 posts.
THREAD STARTER
 
Join Date: Dec 2008
22-Dec-2008, 03:25 PM #1
Hyperlink to specific .pdf page from Excel
Hi All,

I am trying to create a hyperlink in Excel that will open up a specific page from a .pdf file stored on a network drive. Unfortunately I am only able to get the pdf file to open to the first page. Any help would be greatly appreciated!!!!

Thanks!
WendyM's Avatar
Trusted Advisor with 3,997 posts.
 
Join Date: Jun 2003
Location: Northern California
23-Dec-2008, 12:34 PM #2
Hi laguy,
You just need to add #page=[page number] at the end of your link. So if your file is http://www.something.com/file.pdf, and you want it to open to page 3, it would be http://www.something.com/file.pdf#page=3. Hope that helps.
Zack Barresse's Avatar
Computer Specs
Member with 5,434 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
23-Dec-2008, 12:58 PM #3
Wow! Nice Wendy!! I was trying to figure out how to do it via the Object Model. That's so simple!! Learn something new each day.
laguy83's Avatar
laguy83 laguy83 is offline
Member with 32 posts.
THREAD STARTER
 
Join Date: Dec 2008
23-Dec-2008, 12:59 PM #4
Thanks for your help, WendyM. Unfortunately, the problem I have is that the pdf file I am linking to is not online, but rather is stored on a local drive. For some odd reason Acrobat does not allow you to link to individual pages when the pdf file is stored on a local drive - only when it is stored online. Is there another solution, for locally-stored pdf files? Thanks so much.
computerman29642's Avatar
Computer Specs
Member with 2,892 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Intermediate
23-Dec-2008, 01:25 PM #5
Give this code a try

Code:
Sub OpenPDFpage()
    Dim myLink As String
    Dim TargetPage As Double
    Dim objIE As New InternetExplorer

    myLink = "path/filename.pdf" *Replace with your PDF path destination
    TargetPage = 7   'Page number to be shown

    With objIE
        .Navigate myLink & "#page=" & TargetPage
        .Visible = True
    End With
End Sub
This code was found at the link below:

http://excel.tips.net/Pages/T003350_..._PDF_File.html
laguy83's Avatar
laguy83 laguy83 is offline
Member with 32 posts.
THREAD STARTER
 
Join Date: Dec 2008
23-Dec-2008, 01:30 PM #6
Thank you so much for your help computerman. But at the risk of appearing like a total novice....i've never used code before. Can you tell me how exactly I go about using this code, or at least point me in the direction of an FAQ or tutorial or something? I'm good with computers but just have no training in code or macros....
computerman29642's Avatar
Computer Specs
Member with 2,892 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Intermediate
23-Dec-2008, 01:45 PM #7
Do you want to run the code through a button, or by clicking on something in a cell?
Zack Barresse's Avatar
Computer Specs
Member with 5,434 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
23-Dec-2008, 01:47 PM #8
CM, you're getting fast!! Was working on something, but ya beat me to it! Here it uses late binding though, no reference needed...

Code:
Sub TestPDFlink()
    Dim IE As Object, strFile As String, iPageNum As Long
    strFile = "C:\Users\Zack\Desktop\OpenPDF\Book1.pdf"
    iPageNum = 2
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate strFile & "#Page=" & iPageNum
    IE.Visible = True
End Sub
Just copy/paste code into a standard module (Alt + F11, Alt + I, M).

HTH
laguy83's Avatar
laguy83 laguy83 is offline
Member with 32 posts.
THREAD STARTER
 
Join Date: Dec 2008
23-Dec-2008, 01:47 PM #9
I would like to just click on a link in the cell and have it open up the pdf file...is that what you mean?
computerman29642's Avatar
Computer Specs
Member with 2,892 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Intermediate
23-Dec-2008, 01:50 PM #10
Zack, you are the MAN!!!

Can you explain what you mean by late binding?
Zack Barresse's Avatar
Computer Specs
Member with 5,434 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
23-Dec-2008, 01:53 PM #11
You would need a button. The functionality of an inserted hyperlink doesn't give you what you want, but the VBA code does (hence the button). Or you could write more code to if you select that cell, or double click it, or whatever.
computerman29642's Avatar
Computer Specs
Member with 2,892 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Intermediate
23-Dec-2008, 01:55 PM #12
Zack, I was actually working on the double-click option.
Zack Barresse's Avatar
Computer Specs
Member with 5,434 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
23-Dec-2008, 01:59 PM #13
Quote:
Originally Posted by computerman29642 View Post
Zack, you are the MAN!!!

Can you explain what you mean by late binding?
Yup. Late binding does not use references. Early binding does. VBE | Tools | References. All those listed are object models you can reference to your current project (whatever the active project is). Doing so will give you use of the object library and intellisense. When you see my code, I declared the variable as an Object, plus I used the CreateObject() call, which creates the object (if installed on the host computer). The code you had, you would've needed to go to Tools | References, then check the Microsoft Internet Controls control. Then you can use something like Dim IE as InternetExplorer, because traditionally it's not available to the Excel Object Model.

I prefer late binding because it transports to any machine, no need to set references, sometimes references can come up missing if somebody doesn't have a full install, or just versioning you can come up with reference(s) issues. Early binding can be nice, if it is a solution which only you will run and the solution won't move around. If I'm posting to the board and I don't know that, generally I'll use late binding.

Binding is just referring to how you are bound to an object (i.e. what object library you are referencing). Make sense?
computerman29642's Avatar
Computer Specs
Member with 2,892 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Intermediate
23-Dec-2008, 02:03 PM #14
Thanks Zack. Yes, I believe I get what you are saying. If not, I know who to come and ask..LOL!
laguy83's Avatar
laguy83 laguy83 is offline
Member with 32 posts.
THREAD STARTER
 
Join Date: Dec 2008
23-Dec-2008, 02:04 PM #15
Thank you guys all so much. I really appreciate your efforts.

Zack - I used the code you posted:

Sub TestPDFlink()
Dim IE As Object, strFile As String, iPageNum As Long
strFile = "C:\Users\Zack\Desktop\OpenPDF\Book1.pdf"
iPageNum = 2
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate strFile & "#Page=" & iPageNum
IE.Visible = True
End Sub

However, although it does open up the pdf file, it still only takes me to the first page. Any idea how I can target a specific page?

Thanks again!

Brian
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑