Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default 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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving and closing erf Setting up and Configuration of Excel 4 June 18th 08 06:52 PM
Saving and Closing erf Excel Worksheet Functions 3 June 18th 08 05:03 PM
Saving and Closing erf Excel Discussion (Misc queries) 1 June 18th 08 08:38 AM
closing & saving rufusf Excel Worksheet Functions 2 March 5th 06 09:37 AM
Closing a workbook without saving Darrin Henry Excel Programming 2 September 24th 03 02:31 PM


All times are GMT +1. The time now is 02:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"