LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Before close - not always deleting sheet- WHY??

In the ThisWorkbook module I have:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
On Error Resume Next
ThisWorkbook.Sheets("SheetName1").Delete
ThisWorkbook.Sheets("SheetName2").Delete
On Error GoTo 0
Application.DisplayAlerts = True
End Sub

When the user closes the file, the following behavior occurs:

If user says NO to save changes, the sheets are deleted.
If user says YES to save changes, the sheets are deleted. (good so far....)

BUT, if the user makes a change, saves it, then says NO to the save prompt
when closing, the sheets are *not* deleted.

First of all, I don't understand why the user would get the "save changes?"
prompt right after saving on their own (which it does even if they do
nothing else). Second, I don't understand why the sheets aren't deleted in
this situation.

If anyone can explain, I would really appreciate it! (Using xl2002, no
other subs in ThisWorkbook module.)

Regards,

Patti



 
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
code to close an excel sheet without saving it .(via msgbox) Satyam Reddy Excel Worksheet Functions 2 May 14th 08 02:48 PM
how to setup a excel sheet to be protect after save and close file Marco Excel Discussion (Misc queries) 0 March 11th 08 10:56 PM
Excel creating TMP with each save but not deleting on close Aidan Whitehall Excel Discussion (Misc queries) 1 October 10th 07 05:28 PM
Close Hidden Data Sheet Jeff Excel Programming 7 January 8th 05 09:48 PM
Hanging on sheet close Jesse[_4_] Excel Programming 2 December 4th 03 09:21 AM


All times are GMT +1. The time now is 02:05 AM.

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

About Us

"It's about Microsoft Excel"