+ Reply to Thread
Results 1 to 21 of 21

Attach a .PDF file to Excel

  1. #1
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Attach a .PDF file to Excel

    My Excel (Office 2007) has a column that is devoted to job numbers.

    I create my job sheets as .PDF files & save them with job numbers.

    Is there a way where I can click on the job number in Excel & have this open up the relevent .PDF file?

    Any help or pointers appreciated & please bear in mind my knowledge of Excel is limited. Thanks

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Attach a .PDF file to Excel

    Hit Ctrl & K to insert a hyperLink
    Find the File you want to HyperLink to.

    Check this out to remove HyperLink warnings, maybe there are no warnings in xl'07
    http://support.microsoft.com/kb/829072

  3. #3
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    Thanks for that, yes it did what I wanted.

    But is there a way to make it less long winded?

    There is a lot of navigating to get to the correct folder, the path is
    \\Nasbox\Leaflets\Work Sheets\602.pdf

    And the Insert Hyperlink dialogue box doesn't allow for date modified (which would make it quicker to get to relevant file) or a last folder used.

    I have all the .PDF files I want linked to in one folder & they are all numbered 601, 602, 603 etc. So is there a way that if I type in 603 in a particular column in Excel it will automatically link to the 603.PDF file?

    Bet there isn't!!! ???

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Attach a .PDF file to Excel

    =HYPERLINK("C:\Documents and Settings\Martin Wilson\My Documents\"&B1&".pdf")
    where b1 contains doc number
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    Thanks for that but can you elaborate as at the mo I'm not really sure what to do with this?

    =HYPERLINK("C:\Documents and Settings\Martin Wilson\My Documents\"&B1&".pdf")

    I have changed it to my files location
    =HYPERLINK("\\Nasbox\Leaflets\Work Sheets\"&600&".pdf")

    I right clicked on the cell, selected hyperlink, pasted the above, changed the B1 to 600 but keep getting a cannot open the specified file.

    If it was working correctly wouldn't I have to still paste all of that into each cell I wanted the link to work on & then manually adjust each B1 to the number I want?

    Confused???

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Attach a .PDF file to Excel

    i have no idea of your actual path is
    get the properties of doc by right clicking and use that
    you do not use this by selecting hyperlink
    just put
    =HYPERLINK("\\Nasbox\Leaflets\Work Sheets\"&600&".PDF")
    in the cell just as if you were putting =b1
    i think you are linking to a shared drive so you need to link whatever the drive is
    =HYPERLINK("g:\Nasbox\Leaflets\Work Sheets\"&600&".PDF")
    yes you would have to change b1 but you could put a function in b1 to change it to what you need
    Last edited by martindwilson; 12-15-2009 at 06:10 PM.

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Attach a .PDF file to Excel

    Attached is a sample of getting a list of PDF files and hyperlinking to them.
    Enter the Name of the Folder in A2 and hit enter, in your case enter the name Work Sheets, and then hit enter.
    There is a Worksheet_Change event that kicks in the code to get the .pdf files from the named folder, and then creates a HyperLink to those files.

    Make this simple at first, in you C:\ drive make a new folder and Name it "Work Sheets", throw some .pdf files into that folder.

    Open the workbook, enable macros, I believe in xl'07 you need to do something in the tools menu to enable macros in a workbook.

    Enter Work Sheets in A2 and hit enter.

    The code should then produce a list of Hyperlinks to your .pdf files from that folder.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    Hi Dave

    That looked fantastic, unfortunately it didn't work?

    I downloaded the GetPDFs.xls & saved it to my trusted folder where my main excel spreadsheet reside, full of macros & all enabled.

    On my C; drive I created a folder called "Work Sheets" & put 4 .pdf files in it.

    In Cell A2 I tried entering both "Work Sheets" & "C:\Work Sheets"

    Upon hitting Enter nothing happened?

    Under the Developer Tab - Macro Security - Enable All Macros (was checked)

    Macros - Macro Name - ListPics - Run (nothing happened?)

    Any idea why it isn't running?

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Attach a .PDF file to Excel

    Try changing this .
    Please Login or Register  to view this content.
    Run the macro GetPics
    Check the spelling of the folder.

  10. #10
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    Unfortunately that didn't make any difference. Clicking in or hitting enter over A2 produces nothing?
    No error messages, just nowt.

    Am running Win 7, x64 by the way.
    My Work Sheets folder is "C:\Work Sheets"

    If this was working correctly I assume that all the .pdf files would show up in Cell A4 as hyperlinks?

    My macro now reads as below. Any other ideas?

    Please Login or Register  to view this content.
    Last edited by davesexcel; 12-16-2009 at 09:42 AM. Reason: Code needs to be wrapped in Code tags

  11. #11
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Attach a .PDF file to Excel

    Did you run the macro?
    Or just enter the name in A2?
    I am not sure if the worksheet_change is working, that is why I want to see if it works when you just run the macro.
    Last edited by davesexcel; 12-16-2009 at 09:53 AM.

  12. #12
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    I clicked in Cell A2, nothing.

    I ran the Macro, nothing.

    Just to check I'm running the macro correctly.
    Developer Tab - Macros - Macro name - ListPics - Run

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Attach a .PDF file to Excel

    i still maintain =hyperlink () works since it will do exactly the same.
    with the names of the pdfs 100,101,103,.... listed in col a starting a1 then in b1
    =HYPERLINK("g:\Nasbox\Leaflets\Work Sheets\"&a1&".PDF") dragged down will work.
    the key is to get the right path. right vclick a pdf doc select proerties and copy the exact path given in location into the formula.ive just done it on my networked drive fine
    you dont use the path as you have but the mapped path.

  14. #14
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    Ta Martin, I didn't get back to you earlier as I didn't follow what you meant.

    Still not that clear on what you mean, could you explain it to an idiot please?

    The path to where I store the .pdfs is "\\NASBOX\Leaflets\Work Sheets"

    ???

  15. #15
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Attach a .PDF file to Excel

    that might be the path but you must have mapped it to a drive letter. what does it say in the document properties

  16. #16
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    No
    "\\NASBOX\Leaflets\Work Sheets"
    Is the exact path, its a seperate Server connected via ethernet.

    Don't like mapping network drives, they frequantly don 't reconnect.

  17. #17
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Attach a .PDF file to Excel

    Don't like mapping network drives, they frequantly don 't reconnect
    can't say thats what happens in my experience! but i suspect the syntax for connecting to a network path is different but i am unable to test that

  18. #18
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Attach a .PDF file to Excel

    I just read another reply, it appears
    Please Login or Register  to view this content.
    Is no longer available in xl'07, check out RoyUk's blog on an alternative.

    http://excel2007tips.blogspot.com/20...h-in-2007.html

  19. #19
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    Thanks Dave, followed the link & copied the code

    --------------------------------------------------------------------------------------' Module : Module1
    ' DateTime : 09/05/2007 08:43
    ' Author : Roy Cox (royUK)' Website : www.excel-it.com for more examples and Excel Consulting
    ' Purpose : Open all worksheets in a specific folder' Disclaimer; This code is offered as is with no guarantees. You may use it in your' projects but please leave this header intact.
    '---------------------------------------------------------------------------------------
    Option Explicit
    Sub Open_All_Files()
    Dim oWbk As Workbook
    Dim sFil As String
    Dim sPath As String

    sPath = "C:\Work Sheets\"
    'location of files
    ChDir sPath
    sFil = Dir("*.xlsx") 'change or add formats
    Do While sFil <> "" 'will start LOOP until all files in folder sPath have been looped through Set oWbk = Workbooks.Open(sPath & "\" & sFil) 'opens the file

    ' do something
    oWbk.Close True 'close the workbook, saving changes
    sFil = Dir
    Loop ' End of LOOP
    End Sub

    But every time I clicked within Excel it just opened up the Visual Basic Window & then came up with a compile error.
    Too be honest not really sure what this bit of code is meant to do, how I run it or how it creates & displays my hyper-linked .pdfs?

  20. #20
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    Martin, please can you elaborate on your hyperlink method as its not working for me?

    I have selected the Cell A85, right clicked & selected Hyperlink.
    In the address bar I have pasted
    =HYPERLINK("c:\Work Sheets\"&a1&".PDF")
    & click OK

    The text that then appears as a hyperlink is C:\Work Sheets\Add Highlight.PDF

    Now when I click this in the spreadsheet I get a cannot open the specified file?

    If I type over the hyperlink, the number of one of the work sheets, say 557 I get the same error message.

    More help please???

  21. #21
    Registered User
    Join Date
    02-25-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Attach a .PDF file to Excel

    I have attached a sample of the worksheet which may help with advice?

    Column A is the one where the jobs are numbered & where the hyperlink should refer to the individual .PDF file stored at
    \\Nasbox\Leaflets\Work Sheets
    which is a server.

    Thanks
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1