VBA - Disable alerts not working properly for wb.Close

roland99

New Member
Joined
Jul 16, 2015
Messages
6
In an excel 2010 workbook (which I test on a local 2013 version) i have run into the following problem.

After creating a workbook(wb) i need to then close it without saving.
To do this i change DisplayAlerts to false and then back to true after closing.

This works as intended for when I delete a sheet (See below) but not when I do so for the wb later down the track.

However on a 2013 version of excel it works fine and closes the wb automatically.

Does 2010 force an alert when closing a workbook?
Or is there some setting somewhere which is forcing this behavior that can be disabled through code or manually set?


This works fine regardless of version
Application.DisplayAlerts = False
wb.Sheets(1).Delete
Application.DisplayAlerts = True

This only works on 2013
Application.DisplayAlerts = False
wb.Close
Application.DisplayAlerts = True
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi,

Try changing this:

Code:
Application.DisplayAlerts = False
wb.Close
Application.DisplayAlerts = True


to this:

Code:
wb.Close False


Dave
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

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