+ Reply to Thread
Results 1 to 8 of 8

object invoked error causing excel to crash

  1. #1
    Registered User
    Join Date
    06-13-2014
    Posts
    23

    object invoked error causing excel to crash

    I am receiving the following error:

    -2147417848 automation error the object invoked has disconnected from its clients

    Unfortunately, I can't tell where the error is occurring because everytime it happens excel crashes or at least stops responding. I tried waiting it out (about 20 minutes) but no luck. the only thing I can do is force the program to shut down through the task manager.

    The program is designed to pull information from finviz.com (a financial site), filter the data. pull the next round of data and run the filters again. there are a total of 8 queries and i think it gets hung up during the 6th or 7th run through.

    Stepping through the code does not seem practical since each query might pull as many as 300 rows of data that is evaluated in a for/next loop (thats a lot of F8s).

    I am not really sure what to do at this point. Is there some other way to debug this?

    Thanks in advance and please let me know if i can provide additional information.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: object invoked error causing excel to crash

    No workbook, no data, no code. How would you have us diagnose the fault?

    You are, presumably, looping through a list. So put a Stop in place at the start of the loop. Press F5 and see if the first iteration works. If it does, repeat he process until it fails.

    Alternatively, if the list is on a worksheet, remove all the entries but one. Test it. If it works, replace it with the next and test it. Repeat until it fails.

    Hopefully, that will determine which of the sites causes the failure/loop/lock-up/whatever.

    If all the sites work, it must be something to do with the processing of the data.

    Not a lot to add with no information.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-13-2014
    Posts
    23

    Re: object invoked error causing excel to crash

    I have included the code below, but this is more a debugging technique question. The code works fine when either of the individual filters are run, i.e. I remove one of the filters for testing. My intention is to add two more filters.
    Note: at the end of the code I have the application wait 5 seconds before going to the next query. this was an experiment and actually allowed it to run to the 7th query. prior to adding that line it was getting hung up on the 4th.

    Please Login or Register  to view this content.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: object invoked error causing excel to crash

    OK, well I've offered some suggestions about diagnosing the problem (using Stop, primarily, and stepping through the code.)

    Be aware that UsedRange is fickle and it's better to use a specific fully populated column to determine the last row.

    Also, it's sometimes a good idea to have a "get out of jail" card in a Do Loop where you are testing a condition. If the condition isn't met, for some reason, you might not be able to exit the loop. So, maybe put an arbitrary large counter in and exit if that counter is exceeded.

    I would also advise consistent indenting of code within loops and If blocks etc; makes it easier to see what is linked together, for example, what happens before an Exit Do.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    06-13-2014
    Posts
    23

    Re: object invoked error causing excel to crash

    Hi TMS,
    The Stop idea was helpful particularly since there are so many loops. I placed a few of them through out the code and was able to identify the error. As it turned out, it was UsedRange that was producing a extremely large number when Z = 7. No idea why it only happened on 7, but using column A which was always fully populated solved that.
    Unfortunately, it still crashes when I try to run the entire code. However, if I put a Stop in before it goes to the next Z and hit F5 it will make it all the way through without crashing. That has me stumped. I wouldn't care that much if I were the only one who was going to use it, but my intention was to share it with a few people. Any thoughts?
    Thanks.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: object invoked error causing excel to crash

    Well, when you use Stop to halt and step through the code, Evan allowing big chunks to process, you are giving it "thinking time" which sort of implies it' sample timing issue. Speeding up your code may be a good thing or a bad thing, but you probably need to try it. Instead of copying the rows individually, you should build up a range of cells to be copied. If you are copying whole rows, you only need to store a representative cell and then extend the range to EntireRow at the end.

    Where you are looping down column A at the end, instead of selecting the cells in a row or rows, assign them to a range variable and then use that range variable to apply the formatting.

    Basically, you don't want to be selecting anything, either to copy it or format it.

    Once you have made your code as efficient as possible, you can experiment with the delay that you apply at the end of the loop.


    Regards, TMS

  7. #7
    Registered User
    Join Date
    06-13-2014
    Posts
    23

    Re: object invoked error causing excel to crash

    Hi TMS,
    I took your advice and experimented with some ways to eliminate the individual line copies. Ended up using the Union method which works perfectly and is extremely quick. Thanks again for your help.
    Best,
    edopts

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: object invoked error causing excel to crash

    You're welcome.

+ 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. automation error the object invoked -2147417848
    By Proteo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-04-2014, 08:57 AM
  2. [SOLVED] Error: automation error the object invoked has disconnected from its clients
    By siroos12 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 12-24-2013, 08:56 AM
  3. Replies: 7
    Last Post: 05-15-2013, 09:02 AM
  4. Error:The object invoked has disconnected from client.
    By gpnavin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2012, 01:09 PM
  5. Replies: 7
    Last Post: 01-15-2010, 02:34 PM

Tags for this Thread

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