Excel Crashes When Saving Programmatically

neodjandre

Well-known Member
Joined
Nov 29, 2006
Messages
950
Office Version
  1. 2019
Platform
  1. Windows
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
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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.
 
Upvote 0
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
 
Upvote 0
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??
 
Upvote 0
You can open up the task window and watch memory use there. VBA provides no memory management as such.
 
Upvote 0

Forum statistics

Threads
1,211,744
Messages
6,103,678
Members
447,876
Latest member
rodqntr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top