Results 1 to 3 of 3
  1. #1
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts

    error 1004 when opening workboek (XL 2003)

    Hello all,

    I'm running a macro that is opening different Workbooks.
    A lot of workbooks are corretly opened, but on some workbooks I get the following message:
    "error 1004 Run-time error '1004': method 'Open' of object 'Workbooks' failed"

    The VBA code I use is:
    Workbooks.Open Filename:=txtPadDB & "tblDBCs" & CStr(lngACT) & ".xls", ReadOnly:=True

    the strange thing is that if I choose the go to the code and the VBA editor opens, I just pres the [> continue button the code runs without a problem.
    It opens some workbook, en suddenly is stops again with the same error, but again after presing [Continue] it runs that line with out an error.

    What could be the problem here?
    Thanks in advance for your reactions.
    Greetings,

    Patrick Schouten
    (The Netherlands)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: error 1004 when opening workbook (XL 2003)

    Perhaps you're opening the workbooks too quickly - try inserting one or more lines

    DoEvents

    in the code. If that doesn't help, you may have to create a delay by using Application.OnTime.

  3. #3
    3 Star Lounger siflaar's Avatar
    Join Date
    Jan 2001
    Location
    Amersfoort, Netherlands
    Posts
    203
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: error 1004 when opening workbook (XL 2003)

    Hans,

    Thanks for the suggestion.
    The DoEvents did not solve the problem
    I used te following: Application.Wait (Now + TimeValue("0:00:01"))
    Greetings,

    Patrick Schouten
    (The Netherlands)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •