Excel Crashes When Saving Programmatically

neodjandre

Well-known Member
Joined
Nov 29, 2006
Messages
926
Hello,

I have a complex macro which transfers some worksheets from a workbook to another.

This works fine. Then my macro presents a msgbox to the user saying that "your file will now be saved".

After the user clicks OK - the following code is fired:

Code:
wb_new.Close SaveChanges:=True

With Application
.Calculation = calcst
.EnableEvents = True
.ScreenUpdating = True
.StatusBar = False
.DisplayAlerts = True
End With
Now for some reason on some machines Excel crashes when attempting to save the file.

This happens irrespective of the file sizes and the contents of the files. It just crashes saying Excel encountered an error and needs to be closed.

I am scratching my head to know why on most machines it works OK and for some others it crashes...

any ideas?

thanks
Andy
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,687
Office Version
2013
Platform
Windows
There's nothing about your code that is a problem per se. Hard to say - maybe excel is calculating before saving/closing and running into problem during the calculation.
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,770
If the crashing machines are Macs, its because 2004 is not very stable when working across workbooks. Try an explicit save before closing.

Code:
wb_New.Save
wb_New.Close
 

neodjandre

Well-known Member
Joined
Nov 29, 2006
Messages
926
Hello guys,

The crashing machines are Windows XP, Vista ... I think it might be a memory overflow issue... is there a way to check this or put some code in to free up memory somehow??
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,687
Office Version
2013
Platform
Windows
You can open up the task window and watch memory use there. VBA provides no memory management as such.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,709
Messages
5,512,965
Members
408,928
Latest member
Black Vinyl

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top