LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Prompt for Action before closing workbook

Sorry about your loss, however, I did point that out.

"bman342" wrote:

Woops. The data I was archiving was only a small subset of the data in the
entire workbook (I guess I led you to believe that since I was archiving the
data, I didn't need to save the workbook(?)). So "thisworkbook.saved = true"
was causing me to lose changes. No big problem though.

-b

"JMB" wrote:

You could use a Before Close event handler (copy into the Thisworkbook module
in the VBA editor). If the workbook is not archived the workbook remains
open by setting Cancel to true. If it is acrchived, the workbook is closed
(and the saved property is set to true so excel will not ask if you want to
save changes - change this part of the If construct as needed).

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Response As Long
Response = MsgBox("Did you archive the workbook?", vbYesNo)
If Response = vbNo Then
Cancel = True
Else: ThisWorkbook.Saved = True
End If
End Sub


"bman342" wrote:

Going to the well again.

I've recorded a data archiving macro. I would like to ensure that the User
doesn't forget to go through the archiving procedure before shutting down the
Workbook.

Is there a simple macro to prompt for an action before the user shuts down
the workbook (would assume this would work if they attempted to close Excel,
while the workbook was still open)?

Thanks again.



 
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
why it never prompt to save after closing lightstraight Setting up and Configuration of Excel 1 August 21st 06 12:05 PM
User prompt - Open file - Perform action erikhs[_4_] Excel Programming 4 April 11th 06 01:55 PM
No save prompt when closing workbook budfrog130 Excel Discussion (Misc queries) 0 December 6th 05 01:54 PM
Prompt to save on closing Jake Excel Discussion (Misc queries) 7 October 4th 05 12:05 AM
Save? prompt when closing Excel MC Excel Discussion (Misc queries) 4 March 12th 05 10:55 PM


All times are GMT +1. The time now is 10:25 PM.

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"