Workbook Shut Down without Saving problem

G Marshall

Board Regular
Joined
Dec 31, 2002
Messages
134
Hi there

Within an excel workbook I have a visual basic code that shuts the workbook down following a period of inactivity. I have the workbook password protected so that I am the only person who can change anything. All other users only need to view the workbook.

Sub ShutDown()
CreateObject("WScript.Shell").Popup _
"Due to inactivity this workbook is now closing", 2, "ATTENTION"
ThisWorkbook.Close
End Sub

This works fine except that prior to it closing down automatucally, excel asks if I want to save any changes and until I click no in that dialog box the system will not close.

I can set the file properties to ‘read only’ but before it closes automatically it tells me that the file is read only and do I want to save it under a new name.

Is there any way that I can close the workbook down without saving and without the system asking if I want to save it.

Appreciate any help


Gerald
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

texasalynn

Well-known Member
Joined
May 19, 2002
Messages
8,458
Add the display alert command
Code:
Sub ShutDown()
Application.DisplayAlerts = False
CreateObject("WScript.Shell").Popup _
"Due to inactivity this workbook is now closing", 2, "ATTENTION"
ThisWorkbook.Close
Application.DisplayAlerts = True
End Sub
 

G Marshall

Board Regular
Joined
Dec 31, 2002
Messages
134
Hi texasalynn

A big Thanks for that information, it worked perfectly. Dont know how I'd survive without this forum!

Cheers (y)


Gerald
 

Forum statistics

Threads
1,141,153
Messages
5,704,607
Members
421,359
Latest member
Edwardvanschothorst

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