Excel Crashes When Saving Programmatically

neodjandre

Well-known Member
Joined
Nov 29, 2006
Messages
946
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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
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
24,206
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
946
Office Version
  1. 2019
Platform
  1. Windows
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
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
You can open up the task window and watch memory use there. VBA provides no memory management as such.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,717
Messages
5,833,288
Members
430,202
Latest member
Faizal5zl

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
Top