Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default BeforeClose Event

I'm trying to complete a Workbook.BeforeClose event but am having an issue
with it.

When the user closes the workbook, there is code that checks for data on a
certain worksheet. If it finds data, I display a message box with 3 buttons
(Yes, No, Cancel) that tells the user what will happen with each selection.

If the user pushes "Yes", the workbook should close without saving any data

If the user pushes "No", the code should do some stuff to the data and then
close without saving any data.

If the user pushes, "Cancel", the code stops, the workbook stays open and
the user can review the data.

There is no issue with the "Cancel" protion. I'm having trouble with the
"Yes" and "No" portions. I can get the code to do everything else thing I
want it to except an Excel message box is automatically displayed at the end
of the module. The message says "Do you want to save changes......" with
"yes", "no", and "cancel" buttons.

I would prefer to prevent this message from being displayed or my second
choice is to automatically program it to push the "no" button.

Is there a way to prevent this message and close the workbook without saving
the data.

Thanks for the help. This is a terrific resource for issues. Thanks again..

--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default BeforeClose Event

Set the workbook Saved property to True.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"JT" wrote in message
...
I'm trying to complete a Workbook.BeforeClose event but am having an issue
with it.

When the user closes the workbook, there is code that checks for data on a
certain worksheet. If it finds data, I display a message box with 3
buttons
(Yes, No, Cancel) that tells the user what will happen with each
selection.

If the user pushes "Yes", the workbook should close without saving any
data

If the user pushes "No", the code should do some stuff to the data and
then
close without saving any data.

If the user pushes, "Cancel", the code stops, the workbook stays open and
the user can review the data.

There is no issue with the "Cancel" protion. I'm having trouble with the
"Yes" and "No" portions. I can get the code to do everything else thing
I
want it to except an Excel message box is automatically displayed at the
end
of the module. The message says "Do you want to save changes......" with
"yes", "no", and "cancel" buttons.

I would prefer to prevent this message from being displayed or my second
choice is to automatically program it to push the "no" button.

Is there a way to prevent this message and close the workbook without
saving
the data.

Thanks for the help. This is a terrific resource for issues. Thanks
again..

--
JT



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default BeforeClose Event

Before your macro terminates try adding

ThisWorkbook.Saved = True

This should tell Excel that the workbook does not need to be saved.

That said, I believe at least one version of excel had a bug associated with
this, but I don't recall which - hopefully it works for you.

--
Regards,
Tom Ogilvy

"JT" wrote:

I'm trying to complete a Workbook.BeforeClose event but am having an issue
with it.

When the user closes the workbook, there is code that checks for data on a
certain worksheet. If it finds data, I display a message box with 3 buttons
(Yes, No, Cancel) that tells the user what will happen with each selection.

If the user pushes "Yes", the workbook should close without saving any data

If the user pushes "No", the code should do some stuff to the data and then
close without saving any data.

If the user pushes, "Cancel", the code stops, the workbook stays open and
the user can review the data.

There is no issue with the "Cancel" protion. I'm having trouble with the
"Yes" and "No" portions. I can get the code to do everything else thing I
want it to except an Excel message box is automatically displayed at the end
of the module. The message says "Do you want to save changes......" with
"yes", "no", and "cancel" buttons.

I would prefer to prevent this message from being displayed or my second
choice is to automatically program it to push the "no" button.

Is there a way to prevent this message and close the workbook without saving
the data.

Thanks for the help. This is a terrific resource for issues. Thanks again..

--
JT

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
How to get out of BeforeClose event without closing? 42N83W Excel Programming 4 March 11th 05 05:33 PM
problem with beforeclose event Gordon Excel Programming 1 September 30th 04 11:21 PM
ThisWorkBook BeforeClose Event Doug Glancy Excel Programming 0 July 29th 04 12:36 AM
ThisWorkBook BeforeClose Event David Adamson[_4_] Excel Programming 0 July 29th 04 12:32 AM
Cancelling the BeforeClose Event Troy[_5_] Excel Programming 6 December 2nd 03 06:40 AM


All times are GMT +1. The time now is 07:56 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"