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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,687
Office Version
  1. 2013
Platform
  1. 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,779
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
  1. 2013
Platform
  1. Windows
You can open up the task window and watch memory use there. VBA provides no memory management as such.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,645
Messages
5,524,054
Members
409,557
Latest member
Excelinho

This Week's Hot Topics

Top