+ Reply to Thread
Results 1 to 6 of 6

'Microsoft Excel has encountered an problem and needs to close' error while running SaveAs

  1. #1
    Registered User
    Join Date
    06-10-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    4

    'Microsoft Excel has encountered an problem and needs to close' error while running SaveAs

    A macro enabled Excel file has recently started to crash with error message 'Microsoft Excel has encountered an problem and needs to close' while running

    ActiveWorkbook.SaveAs Filename:="C:\Excel\Filename.xls".

    The file was orginally created using Excel 2003 and has worked fine for over two years. The main user of this file upgraded to Excel 2007 about a year ago but the error didn't appear until a few weeks ago.

    I have tried changing the code by declaring string variables for the filename and the path then using the following code to save the file.

    Workbooks(filenameVariable).SaveAs Filename:=pathVariable & filenameVariable

    I have also tried repairing the Office installation, reinstalling Office, changing the destination folder and running chkdsk. The macro still works on Excel 2003. I didn't get a chance to try it on another PC with Excel 2007 but I assume that it would work.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,083

    Re: 'Microsoft Excel has encountered an problem and needs to close' error while running Sa

    At what point does it crash? Does it open OK? Can you use it for a while before it crashes?

    Could the 2007 user have formatted workbook/worksheets such that they are no longer within the bounds of a 2003 worksheet?

    Is there any 2007 style Conditional Formatting? Whole column cell references?

    Does the 2007 user get any warning messages when he saves the workbook, for example, compatibility?

    Does it only fail when you execute the macro(s)?

    As you can see from the questions, there's a lot that you haven't told us. Can you share the code and/or a sample of the workbook?

    Could you recreate the workbook by copying each of the sheets to a new workbook and then restating the code?

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-10-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: 'Microsoft Excel has encountered an problem and needs to close' error while running Sa

    Sorry for the delay in replying. I had difficulty in getting access to the PC with the problem (constantly in use) but I did magage to set up antother PC with Excel 2007 for testing. The problem also occurs consistently on the new PC.

    In answer to your questions:
    Could the 2007 user have formatted workbook/worksheets such that they are no longer within the bounds of a 2003 worksheet?
    No. It still works with Excel 2003 (I assume you mean the number or rows or columns exceeding the 2003 limit).

    Is there any 2007 style Conditional Formatting? Whole column cell references?
    No.

    Does the 2007 user get any warning messages when he saves the workbook, for example, compatibility?
    No.

    Does it only fail when you execute the macro(s)?
    No. It also fails when doing a manual Save As, but only when the file type selected is Excel 97-2003 Worksheet.


    I forgot to mention previously that the file being saved isn't the file with the macros. Other files can be saved in the Excel 97-2003 format without any problems.

    Recreating the workbook as you suggested might work but as there is a sheet for every week and month of the year, it would take some time.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,576

    Re: 'Microsoft Excel has encountered an problem and needs to close' error while running Sa

    Try it on other PC first. Could be some RAM problem.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,083

    Re: 'Microsoft Excel has encountered an problem and needs to close' error while running Sa

    @zbor: the OP said ...
    but I did magage to set up antother PC with Excel 2007 for testing. The problem also occurs consistently on the new PC.
    Last edited by TMS; 04-15-2014 at 08:00 AM.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,576

    Re: 'Microsoft Excel has encountered an problem and needs to close' error while running Sa

    ah, sorry, I saw:
    I didn't get a chance to try it on another PC with Excel 2007 but I assume that it would work.

+ 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 has encountered a problem and needs to close error while loading workbook
    By Pyro Form in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-13-2012, 02:54 AM
  2. Microsoft Office Excel has encountered a problem and needs to close...
    By Laszlo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2012, 05:12 AM
  3. ERROR: Microsoft Office Excel has encountered a problem and needs to close
    By Kathy25 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2011, 09:45 AM
  4. Microsoft excel has encountered a problem
    By Josh_123456 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2007, 03:25 PM
  5. Replies: 2
    Last Post: 04-03-2006, 08:57 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