Results 1 to 16 of 16

Thread: [RESOLVED] What is Runtime Error 400?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Resolved [RESOLVED] What is Runtime Error 400?

    Everytime I try and run a program on my work computer, that works
    fine on my laptop, it crashes. I keep getting a box that comes up
    with a red circle and white "X" in the middle with "400" in the form. All
    I can click is OK and it closes my program. Does anyone know what this
    means? I tried searching and couldnt find anything. I just dont
    understand why it would work fine on one and not on another.

    Quick Program Description --> Open Excel(Using Late Bindings vice the
    Excel library) and copies data into an array. Afterward, displaying a form
    where you can flip between different array data.

    Any help on this would be great. Thanks for all replies in advance.

    Joshua

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What is Runtime Error 400?

    Can you run the program from source on your laptop?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Re: What is Runtime Error 400?

    No, I cannot run from VB6 due to the fact that the Excel file that
    I am opening will be contained in the same folder as the app. Just a
    sec. OK, I copied my excel file to my VB6 folder and yes it runs fine
    from the the source code.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What is Runtime Error 400?

    Well, according to Google, runtime 400 means "Form already displayed; can't show modally" so it would seem like an attempt is being made to show a form that is already visible.

    Have you tried this program on other desktops?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Re: What is Runtime Error 400?

    Yes, I tried on my home PC and everything worked fine also. I am stumped
    right now. I am going to add in some MsgBoxes and see how far I actually
    get before it freezes on my work PC. It might not even make it past Excel
    loading up before the Main Form is shown. Give me a couple of minutes and
    I will reply with my findings.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What is Runtime Error 400?

    So, it would appear that it works fine on desktops, but just not on your laptop.

    To me this does not indicate a problem with your code. It would indicate an issue with your laptop.

    Have you tried installing on a different laptop?

  7. #7
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    579

    Re: What is Runtime Error 400?

    Hi Hack,

    Take another look at post #1, I read it as he has no problems with his laptop, just his work PC.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Re: What is Runtime Error 400?

    Ok, through some MsgBoxes in there and the error is coming up somewhere
    in the following 4 lines of code.

    xlApp.Visible = False
    Set xlBook = xlApp.Workbooks.Open(pather & "\test.xls")
    Set xlSheet = xlBook.Worksheets("CE")
    lastrow = xlSheet.UsedRange.Rows.Count

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What is Runtime Error 400?

    Quote Originally Posted by Steve Grant
    Take another look at post #1, I read it as he has no problems with his laptop, just his work PC.
    I read this just the opposite
    Quote Originally Posted by Joshua Z
    Everytime I try and run a program on my work computer, that works fine on my laptop, it crashes.
    That it works on his desktop but not his laptop.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Re: What is Runtime Error 400?

    OK, below is the line that is throwing the error. Does anyone see anything
    wrong with it? Keep in mind that I am not including the Execl Library.(Dont
    know if this makes a diff.)

    Set xlBook = xlApp.Workbooks.Open(pather & "\test.xls")

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What is Runtime Error 400?

    You are setting a reference to it, right?

    Also, when you run it on a different computer, you have done a formal installation, right? Not just a file copy.

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Re: What is Runtime Error 400?

    Code for the sub is as follows.

    Dim xlApp as Object
    Dim xlBook as Object
    Dim xlSheet as Object
    Dim loop1 as Integer
    Dim loop2 as Integer
    Dim lastrow as Integer

    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = False
    Set xlBook = xlApp.Workbooks.Open(pather & "\test.xls")
    Set xlSheet = xlBook.Worksheets("CE")
    lastrow = xlSheet.UsedRange.Rows.Count

    For loop1 = 1 to lastrow
    For loop2 = 1 to 12
    ce_array(loop1,loop2) = xlSheet.Cells(loop1,loop2)
    Next loop2
    Next loop1

    Set xlSheet = Nothing
    xlBook.Close
    Set xlBook = Nothing
    xlApp.Quit
    Set xlApp = Nothing

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Re: What is Runtime Error 400?

    Nothing looks off?

  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What is Runtime Error 400?

    No, nothing looks off.

    But, back to my old question, you did install it rather than copy it, right?

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Re: What is Runtime Error 400?

    Everything is installed, not copied. This has got me stumped.

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Sep 2007
    Posts
    19

    Re: What is Runtime Error 400?

    OK, I got fixed it. For some reason it wanted

    Set xlBook = xlApp.Workbooks.Open(FileName := pather & "\test.xls")
    vice

    Set xlBook = xlApp.Workbooks.Open(pather & "\test.xls").

    Dont know why it would be picky on 1 PC and not another. Thanks.

Posting Permissions

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



Click Here to Expand Forum to Full Width