+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 20

Looking for a macro to open a pdf file based on a cell value please

  1. #1
    Forum Contributor
    Join Date
    11-03-2012
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2010
    Posts
    216

    Looking for a macro to open a pdf file based on a cell value please

    In my worksheet I have a macro that saves the data to a pdf file.
    I need a macro that will open one of the saved pdf files based on the value in a cell.
    I have tried searching for code but I can't find one that does exactly what I want.
    Sample file attached. Many thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5,392

    Re: Looking for a macro to open a pdf file based on a cell value please

    For starters.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    11-03-2012
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2010
    Posts
    216

    Re: Looking for a macro to open a pdf file based on a cell value please

    Hi bakerman2, Thanks for your reply but sadly nothing at all happens!!!

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5,392

    Re: Looking for a macro to open a pdf file based on a cell value please

    If fName doesn't reflect the correct filename then nothing happens indeed.

    Please Login or Register  to view this content.
    Does the msgbox reflect correct filename ?

  5. #5
    Forum Contributor
    Join Date
    11-03-2012
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2010
    Posts
    216

    Re: Looking for a macro to open a pdf file based on a cell value please

    Hi bakerman2, Yes, message box displays the correct file name.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5,392

    Re: Looking for a macro to open a pdf file based on a cell value please

    Another one that works for me.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    11-03-2012
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2010
    Posts
    216

    Re: Looking for a macro to open a pdf file based on a cell value please

    Hi bakerman2, Sorry. This time it will start acrobat reader dc but with the error message "There was an error opening this document. This file cannot be found.
    I have tried all your suggestions in two workbooks, each macro gives the same result for each workbook.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5,392

    Re: Looking for a macro to open a pdf file based on a cell value please

    I'm 200% certain that both codes work so either your filename isn't correct or the path you provided in your example file is wrong.

  9. #9
    Forum Contributor
    Join Date
    11-03-2012
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2010
    Posts
    216

    Re: Looking for a macro to open a pdf file based on a cell value please

    Ok, I'll do some investigation. Thank you for your help today, much appreciated.

  10. #10
    Forum Contributor
    Join Date
    11-03-2012
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2010
    Posts
    216

    Re: Looking for a macro to open a pdf file based on a cell value please

    Hi bakerman2, I had a good look at this last night and did find one or two issues with the file names, trailing spaces and the routine I use to save my files to pdf actually adds - in between the ranges. However I have tried using the insert hyperlink method only to find that they will not work either, error message saying "Cannot open the specified file", I also tried using hyperlinks to numerous pdf files not created by the Excel macro I use to save to pdf and they all open fine. Do you think that the macro I use to save Excel to pdf can be rectified to make them work?

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In the Doldrums
    MS-Off Ver
    2010 32bit
    Posts
    1,607

    Re: Looking for a macro to open a pdf file based on a cell value please

    Does this work?

    Please Login or Register  to view this content.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Dynamic resize form and controls?
    One year calendar in UserForm
    *******************************************************

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5,392

    Re: Looking for a macro to open a pdf file based on a cell value please

    Post the code U use to save to pdf.

  13. #13
    Forum Contributor
    Join Date
    11-03-2012
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2010
    Posts
    216

    Re: Looking for a macro to open a pdf file based on a cell value please

    mc84excel, Thanks for your code, but no luck, I will open other files but not ones created by the macro I have used to create pdf from my worksheet. Many thanks anyway.

  14. #14
    Forum Contributor
    Join Date
    11-03-2012
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2010
    Posts
    216

    Re: Looking for a macro to open a pdf file based on a cell value please

    Hi bakerman2, I have attached a workbook with the code in a module as I don't seem to be able to post the code for some reason. The cell refs will all be different to the sample file I sent you in the first instance.
    Attached Files Attached Files

  15. #15
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    5,392

    Re: Looking for a macro to open a pdf file based on a cell value please

    1. Where does 'currentmonth' come from ??

    2. Where is 'AlwaysOverwritePDF' set ??

+ Reply to Thread
Page 1 of 2 1 2 LastLast

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