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
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

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
 

Watch MrExcel Video

Forum statistics

Threads
1,111,493
Messages
5,541,041
Members
410,543
Latest member
ExcelGlenn
Top