+ Reply to Thread
Results 1 to 5 of 5

Excel 2010 crashing on Close

  1. #1
    Registered User
    Join Date
    04-27-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    9

    Excel 2010 crashing on Close

    Hi there, hope somebody can help or advise:
    I have the following code associated with a button on a form which should save and close an excel file:
    Please Login or Register  to view this content.

    I also have the following code in the Thisworkbook Object which replicates some of what the button referred to above does (the below was not working for some reason so I placed the same code into the button to ensure it runs).

    Please Login or Register  to view this content.
    For some reason Excel 2010 crashes about 20% to 50% of the time when I use the button to close the Excel file. I'd be grateful in anyone could advise me as to what might be causing this. Perhaps it might also help if I say that the Excel file is saved as a 2003 (.xls) file as it needs to run on other computers operating Excel 2003, and that I generally find Excel 2010 to be more unstable that 2003.

    Many thanks

    Is

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    3,974

    Re: Excel 2010 crashing on Close

    Hi there,

    The first thing I'd try is to remove the "Unload Me" statement from the "Button_Click" routine.

    Unloading a UserForm removes it from memory, so any subsequent attempts to access the code it contains are likely to be hit-and-miss at best!

    If you want to remove the UserForm from the screen while your shutdown routines are running you should instead use:


    Please Login or Register  to view this content.
    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Last edited by Greg M; 11-18-2013 at 08:00 PM. Reason: Added "subsequent"

  3. #3
    Registered User
    Join Date
    04-27-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Excel 2010 crashing on Close

    Many thanks for responding. I'm afraid it still crashes with the "Unload Me" removed.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    3,974

    Re: Excel 2010 crashing on Close

    Hi again,

    Try removing or "commenting out" the Workbook_BeforeClose routine and see if the crash still occurs.



    Also, this shouldn't cause a crash, but I think there's an inconsistency between your UserForm routine which says:


    Please Login or Register  to view this content.

    and your Workbook_BeforeClose routine which says:


    Please Login or Register  to view this content.

    Please let me know how you get on with the above.

    Regards,

    Greg M

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Excel 2010 crashing on Close

    I could not replicate your problem.

    You're going to get an alert every time asking if you want to save since you're changing the workbook through code.

    Also, your variable i is not defined or given a data type. I used code 10 times and it closed just fine 10 times. Might be something else in your workbook or on your PC.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

+ 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. Excel 2010 crashing when running macros....my code?
    By dietcoke802 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2013, 05:56 PM
  2. [SOLVED] Excel 2010 crashing on opening a XLSM
    By SonOfOdin in forum Excel General
    Replies: 4
    Last Post: 04-18-2013, 08:05 AM
  3. Replies: 10
    Last Post: 03-13-2013, 06:15 AM
  4. [SOLVED] Excel 2010 crashing when closing file
    By Albatros in forum Excel General
    Replies: 4
    Last Post: 06-13-2012, 12:52 PM
  5. Macro is crashing Excel 2010
    By kahss33 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-15-2011, 10:04 AM

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