+ Reply to Thread
Results 1 to 5 of 5

VBA code to open .pdf's saved in different folder locations

  1. #1
    Registered User
    Join Date
    04-05-2016
    Location
    London
    MS-Off Ver
    2007
    Posts
    3

    Red face VBA code to open .pdf's saved in different folder locations

    Hi,

    Looking for some help creating a VBA code or IF function that will open a .pdf based on values within 2 different cells.

    For instance Column F can have a range of Chapter numbers e.g 32, 52, 55 etc. which relate to specific folder names saved on a drive (for this example: my desktop)

    I.E

    C:\Users\(USERNAME)\Desktop\32
    C:\Users\(USERNAME)\Desktop\52
    C:\Users\(USERNAME)\Desktop\55

    Column M has .pdf file names such as

    Chapter32_drawing1.pdf
    Chapter32_drawing2.pdf

    Chapter52_drawing1.pdf
    Chapter52_drawing2.pdf

    Essentially I want to create a hyperlink in Column N, that will find a specific (Chapter) folder based on the value of Column F, and return the file name based on information in column M.

    Cell F2 = 32 + Cell M2 = Folder 32 + Chapter32_drawing1.pdf
    Cell F3 = 52 + Cell M3 = Folder 52 + Chapter52_drawing1.pdf

    Then the N Column hyperlink automatically opens the .pdf

    N2 = C:\Users\(USERNAME)\Desktop\32\Chapter32_drawing1.pdf

    N3 = C:\Users\(USERNAME)\Desktop\52\Chapter52_drawing1.pdf

    The Chapter folders need to exist for the sake of organising the drawings inside them, I know this would be much simpler if all the drawings were in one Folder.

    Any help would be amazing!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA code to open .pdf's saved in different folder locations

    I can't figure out what you have in column M. First it looks like a full PDF file name but then it looks like a folder number. In particular this notation is a mystery to me:

    Cell F2 = 32 + Cell M2 = Folder 32 + Chapter32_drawing1.pdf

    If

    F: Folder number
    M: Full PDF file name

    then this should do it:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-05-2016
    Location
    London
    MS-Off Ver
    2007
    Posts
    3

    Re: VBA code to open .pdf's saved in different folder locations

    Thank you so much that worked perfectly!

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA code to open .pdf's saved in different folder locations

    You're welcome! By the way, this does not involve VBA. Usually when posing a question it is best to describe what you want to do, rather than starting with how you think it will need to be done. That way you will get a better spectrum of answers. There could also be a VBA solution to this if for some reason you need to avoid the HYPERLINK formulas.

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon addreputationiconsmall.jpg below their name.

  5. #5
    Registered User
    Join Date
    04-05-2016
    Location
    London
    MS-Off Ver
    2007
    Posts
    3

    Re: VBA code to open .pdf's saved in different folder locations

    Thank you for the Tips, as you are probably aware this is my first post so I wasn't quite sure of the forum etiquette. For now there is no reason why I cant use the hyperlink formula. Once again thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  2. Replies: 0
    Last Post: 11-16-2017, 09:15 PM
  3. [SOLVED] Modify the code to consolidate files in same order as saved in source folder
    By Masa1989 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-17-2015, 09:21 AM
  4. Replies: 1
    Last Post: 08-07-2015, 10:47 AM
  5. VBA open yesterdays saved file in a specific folder
    By forfiett in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2014, 08:17 AM
  6. [SOLVED] Code to Open the Folder i just saved to in VBA?
    By JungleJme in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-07-2013, 08:31 AM
  7. Open outlook saved messaged from a folder through the click of a button in excel
    By chris2 in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 09-20-2012, 11:06 AM

Tags for this Thread

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