+ Reply to Thread
Results 1 to 3 of 3

If statement when Run-Time Error Code 490 is displayed onscreen

  1. #1
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    225

    If statement when Run-Time Error Code 490 is displayed onscreen

    Hi all, I have tried to find without luck some help regards the onscreen message "Cannot open the specified file" which is error code 490.

    In my VBA projects I normally use the "On Error GoTo ErrHandler:" line and then write in an If statement for a given error code.

    My worksheet cell's contain hyperlinks, the formula's within the cell's are written correctly and point to the correct file path etc but if the actual file does not exist, the onscreen message is shown "Cannot open the specified file", this is where I want to change what happens.

    Is there a way via VBA to disable the message from being shown and at the same time run some code via the If statement.

    I know its not really an error as such but wanted to see if I could use the response to trigger something different.

    Thank you to anyone who could help.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: If statement when Run-Time Error Code 490 is displayed onscreen

    You could 'intercept' the hyperlink using the sheet's FollowHyperlink event which looks like this.
    Please Login or Register  to view this content.
    Target represents the hyperlink that's been clicked and you could use code in the event to check if it's valid/if the file exists.

    If there is a problem with the hyperlink you should be able to handle it yourself.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    11-23-2004
    Location
    Bristol
    MS-Off Ver
    2016
    Posts
    225

    Re: If statement when Run-Time Error Code 490 is displayed onscreen

    Hello Norie, I tried using your method but nothing happens.

    Please Login or Register  to view this content.
    Can I be missing something really simple?

+ 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. Run time Error in If else statement clause
    By gandhiaditya in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-21-2016, 01:55 AM
  2. Run time error '400' form already displayed cant show modally
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-08-2014, 04:56 AM
  3. Need to add if error code to worksheet change event to stop a run-time error
    By KT99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2014, 03:10 PM
  4. Replies: 4
    Last Post: 11-15-2013, 05:03 PM
  5. VBA Code for IF Statement returns Run-Time Error 1004
    By esphero in forum Excel General
    Replies: 3
    Last Post: 03-22-2012, 07:06 AM
  6. If statement run time error
    By slim1313 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-14-2009, 01:41 PM
  7. [SOLVED] Run-time error '9' on With statement
    By xlcharlie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-28-2005, 03:10 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