+ Reply to Thread
Results 1 to 10 of 10

If file isnt found, navigate to another specific file.

  1. #1
    Registered User
    Join Date
    06-28-2012
    Location
    Leicestershire
    MS-Off Ver
    Excel 2007
    Posts
    14

    If file isnt found, navigate to another specific file.

    Hello all,
    I'm sure this will be a simple fix, but I'm a bit stuck on something.

    I've built a dashboard tool that amougsnt other things displays a pdf image (of a store plan) in a web browser control.
    The user simply selects the particular shop they want to view from a drop down list in cell C3.
    The store names in the drop down are all in the same format. (Unique four digit number, space, store name)
    e.g.
    4600 ABERDARE
    4147 ADEL

    All the pdf's are stored in one folder and are saved as just the store name. e.g. \\uknts8005\cad\store planning\dashboard\PLAN PDF\ABERDARE.pdf

    This is the code used to display the correct pdf, and it works perfectly. Assuming there is a pdf.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The problem is when the pdf is missing or spelled incorrectly. It will display this message where the pdf should be:
    no-pdf.jpg

    What I'd like is to display a custom message on a pdf if the store plan isn't found.
    Lets say the location is: \\uknts8005\cad\store planning\dashboard\PLAN PDF\ErrorMsg.pdf

    How can I get it to naviagte to the error pdf only when the orginal pdf isnt found?
    Everything I've tried just makes the error pdf show all the time, no matter what!

    Thanks

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: If file isnt found, navigate to another specific file.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-28-2012
    Location
    Leicestershire
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: If file isnt found, navigate to another specific file.

    Thanks but this doesn't seem to work?
    If completed it as such
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: If file isnt found, navigate to another specific file.

    Please expain what doesn't work. Is it not triggering the error code? I don't have any personal experience working with web browsers, so it may be that the web browser navigation has its own error handling, and therefore comes back clean to VBA. If that's the case, I'll have to defer to someone with experience in this area.

  5. #5
    Registered User
    Join Date
    06-28-2012
    Location
    Leicestershire
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: If file isnt found, navigate to another specific file.

    Yes exactly. Its not showing the error message pdf when its unable to find the correct one.
    Just displaying the same message as as in my first post "no-pdf.jpg"

  6. #6
    Registered User
    Join Date
    06-28-2012
    Location
    Leicestershire
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: If file isnt found, navigate to another specific file.

    I managed to collar a mate of mine from IT and he solved it straight away;

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Post Re: If file isnt found, navigate to another specific file.

    Very good. Might I suggest, for several reasons:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-28-2012
    Location
    Leicestershire
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: If file isnt found, navigate to another specific file.

    Thanks Natefarm, your solution is neat. Please forgive my ignorance, but could you explain why it's better? I'm always keen to learn.
    cheers

  9. #9
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: If file isnt found, navigate to another specific file.

    Putting the file & folder name in variables makes the code much easier to read by separating out the cluttered names away from the code. It also allows you to use the variables in multiple locations without having to spell them out each time. Thereafter, if you change the file or folder name, you only have to do it in one place.
    Putting the file & folder name in separate variables allows you to use them separately (as in the example).

    In fact, I seldom put folder & file names in my code. I prefer to put them in named cells so they can be maintained by users without needing to update the code. This also makes testing (with test file names and folders) and production distribution easier.

    To do that the code would be:

    Please Login or Register  to view this content.
    Just remember to include the final "/" in the folder name, or put code in to check for it and add it if needed.

  10. #10
    Registered User
    Join Date
    06-28-2012
    Location
    Leicestershire
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: If file isnt found, navigate to another specific file.

    Adding the folder and file names into cells is actually a very good idea. I'm about to hand over the management of this dashboard to someone with less experience than me. So this might help them make any future changes.
    Thanks for all your help Natefarm, I really appriciate it.
    Happy Holidays!

+ 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. Copying file but receive an Run-time error'53' - File not found
    By jeffreybrown in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-02-2013, 06:40 PM
  2. Excel 2010 file with VBA save and send code works-but file can't be found.
    By carlton.clay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2013, 09:46 AM
  3. [SOLVED] a macro that will close the workbook when a certain file in the network isnt present?
    By kjy1989 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-08-2013, 12:14 AM
  4. How to change closed file name - Error: file not found
    By PGM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2006, 09:10 AM
  5. Replies: 1
    Last Post: 02-10-2005, 07:06 PM

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