+ Reply to Thread
Results 1 to 14 of 14

Saving and Closing workbook leaves a blank excel shell open, why?

  1. #1
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Saving and Closing workbook leaves a blank excel shell open, why?

    I have a report that i automated by the task scheduler and for some time i was ok with it staying open once it processed as i was already in other excel files working, so wasn't a big deal, last week i added the following to the processing and having some weird side effects.

    This code works on saving and closing the file, BUT it leaves the excel shell open, meaning that the excel application is open, but no workbook is open.

    Please Login or Register  to view this content.
    All i want to do is close that instance of excel that was just opened and processed.
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    You need Application.Quit to close the application.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    So just update it to this?

    Please Login or Register  to view this content.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    Yes, unless the code is actually in the active workbook, in which case just save the active workbook, then quit.

  5. #5
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    The report is scheduled to run tomorrow morning, so ill know if it works then, since it already ran and processed todays files, i cant test it now.

  6. #6
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    So my report just ran with the this code and still left the excel shell open after finishing.

    Please Login or Register  to view this content.
    So my actual report workbook closes and saves with the latest updates, but after that closes, the excel shell is left behind.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    Is the code in that workbook?

  8. #8
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    Nope, its in my Module2 and called from my Module1 like this:

    ' Save and Close workbook
    Call Module2.SaveAndClose

    Its not so much an issue, more of a nuisance than anything else. But it would be nice to have it close once complete, specially if im not in excel at that moment.

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    Which workbook are those modules in? The one the code is closing or a different one?

  10. #10
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    same workbook that is being closed.

    So my workbook which has the 2 modules is the one that is opened by a scheduled task at a certain time(9am) then in the "ThisWorkbook" object im using the Workbook_Open() and is where i call my sub that is in Module1
    Please Login or Register  to view this content.
    , which is where all the calls are made for the rest of the subs.
    Now that im typing it out, i think when you asked earlier in the posts, i stated incorrectly.



    The routine that is called in the above is the following:

    Please Login or Register  to view this content.

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    If it's the workbook with the code in that is closing, you need something like:

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    Quote Originally Posted by rorya View Post
    If it's the workbook with the code in that is closing, you need something like:

    Please Login or Register  to view this content.
    I have made the update and will post back tomorrow morning once it runs again.
    thank you

  13. #13
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    Quote Originally Posted by rorya View Post
    If it's the workbook with the code in that is closing, you need something like:

    Please Login or Register  to view this content.
    this did the trick, opened, processed, saved and closed within 2 seconds.. thank you

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Saving and Closing workbook leaves a blank excel shell open, why?

    Glad we could help.

+ 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. clean method for closing excel file without leaving a shell or closing other excel files
    By QuantumSquirrel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2020, 08:20 AM
  2. Replies: 2
    Last Post: 12-30-2019, 06:07 PM
  3. [SOLVED] Closing Open Workbook Without Saving
    By Brontosaurus in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 06-19-2019, 09:36 AM
  4. Saving personal workbook before closing excel
    By Thor Almighty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2015, 06:27 AM
  5. Creating new workbook, saving as csv and then closing - but closing always fails.
    By ella626 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2014, 10:05 PM
  6. Replies: 3
    Last Post: 01-06-2009, 01:09 PM
  7. I need to auto exit MS Excel when user leaves workbook open over .
    By Jacques in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2005, 10:06 AM

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