+ Reply to Thread
Results 1 to 5 of 5

Excel crashes when macro gets workbook to close

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Excel crashes when macro gets workbook to close

    Hi there all,

    I'm encountering a problem with Excel 2007. I have a userform with a command button that automatically closes the userform (which takes up the whole screen and hides the workbook behind it) and exits the application/active workbook. It achieves this and the Workbook closes. However, about 2 seconds after the close, a pop-up appears with Microsoft Excel has encountered a problem and needs to close.

    I've not been able to find anything on the web regarding the same problem, but I did come across an issue someone was having with the closing of a userform and having to unload the user form appropriately before close. That shouldn't be a problem with my code though as upon the exit command button procedure, I have used an unload me command to take it away before an activeworkbook.close command. The standard save pop-up comes up. I click no - not to save changes, and that's when the error occurs.

    What am I doing wrong? Any ideas? Are there any rules I am not following?
    Last edited by Julesdude; 02-23-2011 at 12:50 PM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Excel crashes when macro gets workbook to close

    Just an example of what I have for a survey that I created:
    Unload Me
    MsgBox "Thank you for taking part in this survey.  Your opinions are greatly appreciated"
    ActiveWorkbook.Save
    Application.Workbooks("Charting Tool Survey.xls").Close
    This works well for me. However, to make it not save while closing or so the prompt does not come up, I do not know.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Re: Excel crashes when macro gets workbook to close

    Thanks Mordred, but it's still not working for me. I don't use the activeworkbook.save command. But even if I do it still crashes.

    What I do use is the activeworkbook.saved = True. This is because updates are saved perviously and I don't want the prompt default pop-up to come up when exiting.

    Still need help.

  4. #4
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Re: Excel crashes when macro gets workbook to close

    Are there any rules I should be using to avoid this closing Excel bug/issue?

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

    Re: Excel crashes when macro gets workbook to close

    As a general rule, I never allow userforms to unload themselves - they only hide and then whatever routine loaded them does the actual unloading.
    Everyone who confuses correlation and causation ends up dead.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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