Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing Workbook without Saving
Hi..
I'm attempting to write some code that will simply prevent a workbook from saving changes and close (without any display alerts) when the "X" is clicked. Tried this: Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Close SaveChanges:=False End Sub however this results in Excel crashing...you can't select a cell in the underlying workook that becomes the active once this file closes. If you attempt to select another sheet in it - crash..!! Any help appreciated - I run Excel 2000 Rgds Chris |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing Workbook without Saving
Here you go, try this:
Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Saved = True ThisWorkbook.Close End Sub -----Original Message----- Hi.. I'm attempting to write some code that will simply prevent a workbook from saving changes and close (without any display alerts) when the "X" is clicked. Tried this: Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Close SaveChanges:=False End Sub however this results in Excel crashing...you can't select a cell in the underlying workook that becomes the active once this file closes. If you attempt to select another sheet in it - crash..!! Any help appreciated - I run Excel 2000 Rgds Chris . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing Workbook without Saving
Chris Gorham wrote:
I'm attempting to write some code that will simply prevent a workbook from saving changes and close (without any display alerts) when the "X" is clicked. Tried this: Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Close SaveChanges:=False End Sub Try Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Saved = True End Sub Bill Manville MVP - Microsoft Excel, Oxford, England No email replies please - reply in newsgroup |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Saving and closing | Setting up and Configuration of Excel | |||
Saving and Closing | Excel Worksheet Functions | |||
Saving and Closing | Excel Discussion (Misc queries) | |||
closing & saving | Excel Worksheet Functions | |||
Closing a workbook without saving | Excel Programming |