+ Reply to Thread
Results 1 to 7 of 7

Excel crashes when closing an Active Workbook with VBA

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Excel crashes when closing an Active Workbook with VBA

    When I run my macros on Excel it crashes at:

    ActiveWorkbook.Close savechanges:=True

    The workbook is saved but it quits excel application. So if I have other excel files open, all the files are closed.

    I also tried ActiveWorkbook.Close because I save it first anyway.
    But then also it crashes.
    However when I block the close line from the macro it runs fine and no crashes.
    But oufcourse I rather have the workbook closed automatically after it is saved.

    This is the part of my code that goes wrong:
    Please Login or Register  to view this content.
    Does anybody know why it keeps crashing on me and how it could be solved?
    Thanks!

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Excel crashes when closing an Active Workbook with VBA

    may be Disable the events and try...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Excel crashes when closing an Active Workbook with VBA

    Tried now several runs with your solution and seems not to be crashing anymore
    Thanks a bunch!

  4. #4
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Excel crashes when closing an Active Workbook with VBA

    Apparently I spook too soon
    Yesterday all day all went fine but when I try my macro today it still crashes everytime....
    Getting a bit frustrated....
    Anybody more suggestions about what could cause this anoying behaviour?

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Excel crashes when closing an Active Workbook with VBA

    I don't have any other suggestions with me

    I will call for all members help for this thread

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Excel crashes when closing an Active Workbook with VBA

    "...So if I have other excel files open, ..."

    add the line:
    Please Login or Register  to view this content.
    before the close code to verify the file being closed is the intended one.
    Ben Van Johnson

  7. #7
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: Excel crashes when closing an Active Workbook with VBA

    Hi,

    Try this formula instead?

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Thanks
    Lex

+ 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. Closing non-active workbook
    By patelh9 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2010, 12:09 AM
  2. Excel 2007 Hangs & Crashes on closing
    By shregger in forum Excel General
    Replies: 1
    Last Post: 01-20-2010, 10:42 AM
  3. closing the active workbook
    By jmoffat in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-03-2006, 08:21 AM
  4. Closing Hidden Workbook when Active Workbook is Closed
    By SusanK521 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-23-2005, 08:05 PM
  5. [SOLVED] Excel crashes after closing workbook
    By James W. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2005, 06:05 PM

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