1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Error 1004 - unable to read file

Discussion in 'Business Applications' started by Unusual, Jan 20, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. Unusual

    Unusual Thread Starter

    Joined:
    Jan 22, 2009
    Messages:
    92
    Hi All

    I have an interesting problem that I would really appreciate assistance solving.


    I have the following simple code in a VBA Excel module:

    Set BookResults = Workbooks.Open("C:\MVAA\trial.xls")

    This code always used to work fine no problems in Office 2007. Then all of a sudden I started occasionally getting an error "Error 1004 - unable to read file"

    A few days ago I upgraded to Office 2010. Now every time I run this code the first time it works fine...but then if I try and run it again I get the same error! The only way around this is to restart my PC!

    I am really scratching my head about this one

    Any ideas?

    Thanks a lot
     
  2. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,590
    First Name:
    Hans
    Really is strange, the line of code you're using works fine here (other folder and filename) but it works.
    I used Excel 2007 to test it.

    Did you change your 'trusted environment' ? Maybe you updated virus definitions?
    No further bright ideas on this side, sorry
     
  3. Unusual

    Unusual Thread Starter

    Joined:
    Jan 22, 2009
    Messages:
    92
    Thanks Keebellah I added the folder where these files are stored to my "trusted locations", but I haven't experienced any other problems as a result of this. Also doesn't seem to be linked to anti virus software at all. Thanks anyway
     
  4. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,590
    First Name:
    Hans
    I Googled on Excel "Error 1004 - unable to read file" and got quite a lot of hits (also this forum) but many others and it seems there's an issue but no one can really pinpoint it.
    Maybe it's an IDFLDAT error...


    I Don't Feel Like Doing Anything Today :)
     
  5. Unusual

    Unusual Thread Starter

    Joined:
    Jan 22, 2009
    Messages:
    92
    Yes...I also got the feeling that it is something very broad that is not so simple to fix. At this stage I would be more than satisfied to at least to try and find some sort of workaround, even if the issue cannot be resolved fully. Thanks again
     
  6. Unusual

    Unusual Thread Starter

    Joined:
    Jan 22, 2009
    Messages:
    92
    Excuse my ignorance but what is an IDFLDAT Error?
     
  7. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,590
    First Name:
    Hans
    Didn't you read my answer??????

    I Don't Feel Like Doing Anything Today :)
     
  8. Unusual

    Unusual Thread Starter

    Joined:
    Jan 22, 2009
    Messages:
    92
    Oooooh...sorry, I thought that was some sort of status update of yours. Didn't realize that it related to my query! Well let me know if you get any other ideas how to beat it back into shape and to start wanting to work again! Thanks
     
  9. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,590
    First Name:
    Hans
    Sorry,I did some testing but cannot find a plausible reason. :( (n)
     
  10. etaf

    etaf Moderator

    Joined:
    Oct 2, 2003
    Messages:
    65,252
    First Name:
    Wayne
    opened at posters request
     
  11. Unusual

    Unusual Thread Starter

    Joined:
    Jan 22, 2009
    Messages:
    92
    Hi All

    I just wanted to let everyone know that I managed to stumble across a solution to my problem although I haven't the foggiest idea why it works!!!

    If I add in a MessageBox one line before the problematic line that crashes, then this prevents the crash!!!

    I tested it many times and it seems to work every time.

    Bizarre but at least it sorts it out.
     
  12. Unusual

    Unusual Thread Starter

    Joined:
    Jan 22, 2009
    Messages:
    92
    I found an even easier solution. Instead of using a messagebox just before the line that crashes, I created a one second delay in the program which achieves the sames purpose.

    To do this I used:

    Application.Wait Now + TimeSerial(0, 0, 1)

    Does the trick!

    Hopefully this will help anyone else with the same problem.
     
  13. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/975781

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice