Can't get Excel to unload...help!

Discussion in 'AutoCAD' started by pogoblue, Dec 29, 2004.

  1. pogoblue

    pogoblue Guest

    I have a unique problem that I just ran across. I have a routine which opens Microsoft Excel, performs a process using an Excel file, then closes the file, exits Excel, AND sets both container variables = nothing. However, Excel still will not leave memory. The only way to get it to leave memory is to unload the DVB file.

    Now, when I try to unload the DVB file I have the following problems: when I hard-code a Application.UnloadDVB it fails for the obvious reason that it cannot unload itself. If I hard-code an Application.Sendcommand and use the VBAUnload command, it does not unload the file (resident on a network drive). If I program the VBAUnload command into the button that executes the DVB file, it never runs the command.

    Anyone who has seen something like this and could provide a solution would be most helpful!

    Thanks!
    Jeremy
     
    pogoblue, Dec 29, 2004
    #1
  2. Jeremy,

    You're not alone in this problem...it's been around for years. One
    thing I found that usually works for me is to place the Excel code in a
    class module (that you create and destroy properly). This get around
    the unloaddvb issue.

    Also, make sure you clear the worksheet, workbook and excel objects (in
    that order).

    Good luck,

    Jim Dowthwaite
     
    jim.dowthwaite, Dec 29, 2004
    #2
  3. pogoblue

    Ed Jobe Guest

    Its not unique, to you that is. If you search this ng, (try "unload excel"),
    you will find numerous discussions on the problem. The only thing that is
    unique is that excell seems to be one of the few programs with this problem.

    --
    ----
    Ed
    ----
    opens Microsoft Excel, performs a process using an Excel file, then closes
    the file, exits Excel, AND sets both container variables = nothing.
    However, Excel still will not leave memory. The only way to get it to leave
    memory is to unload the DVB file.
    I hard-code a Application.UnloadDVB it fails for the obvious reason that it
    cannot unload itself. If I hard-code an Application.Sendcommand and use the
    VBAUnload command, it does not unload the file (resident on a network
    drive). If I program the VBAUnload command into the button that executes
    the DVB file, it never runs the command.
     
    Ed Jobe, Dec 29, 2004
    #3
  4. pogoblue

    Kevin L. Guest

    and if your program stops for debugging or error out, Excel.exe will be in
    the list of running processes, but not on the taskbar also...

    kevin
     
    Kevin L., Dec 29, 2004
    #4
  5. pogoblue

    bcoward Guest

    You will find a Microsoft Knowledge Base article that will indicate using the Activate or Select methods helps cause this problem
     
    bcoward, Jan 1, 2005
    #5
  6. pogoblue

    pogoblue Guest

    Do you have a link for the article? I have not been able to come up with one using the search terms I can think of. Thanks!
     
    pogoblue, Jan 3, 2005
    #6
  7. Paul Richardson, Jan 3, 2005
    #7
  8. pogoblue

    Ed Jobe Guest

    I think he was talking about the MS article that Bob referred to.
     
    Ed Jobe, Jan 3, 2005
    #8
  9. Paul Richardson, Jan 3, 2005
    #9
  10. pogoblue

    pogoblue Guest

    Latest update...I did some more poking around in my code and happened to notice that I did not use either the Activate or Select methods for any of my objects. I have read that you can run into this problem if you do not use absolute names with everything (i.e. Application.Worksheets.Sheet(1).Item...yada yada), but I believe the coding I have is as absolute as possible. The most confusing part is that a week before I ran into this error it did not occur, and the code was the same as it is now. Still researching on my end...any more help would be great: the articles have been especially helpful!

    Thanks!
     
    pogoblue, Jan 3, 2005
    #10
  11. pogoblue

    pogoblue Guest

    AHA!!! I found my loose reference: I used Workbooks.Open instead of MyXL.Workbooks.Open to open the Excel workbook that I needed to reference. Once I reran the routine Excel loaded into memory and then unloaded as it should. In the process of research, I found this interesting Microsoft Knowledge Base Article:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;199219

    Which I believe could be useful for anyone else who encounters this problem. Thanks again for all of your help!
     
    pogoblue, Jan 3, 2005
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.