Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I hate to be a pest, but, I think I'm nearing completion of my project.
Since my workbook is being used as a data entry front-end, I do not want Excel to ask the user about saving changes (to the workbook). In my code, I know if the user has saved his data to the database. If the user tries to close or exit without having saved the data, I want to give him a chance to save it, then close or exit. This is the code I've tried and the results. If someone can see that I'm doing something wrong, or, better yet, if anyone knows how to do this correctly, I would be greatly appreciate some feedback. In "ThisWorkbook" Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim intResponse As Integer intResponse = MsgBox("Data Not Saved, Quit anyway?", vbYesNoCancel, "Not Saved") If intResponse < vbYes Then Cancel = True Exit Sub Else 'Prevents this event from being triggered a second time Application.EnableEvents = False 'Don't display the save changes dialog ThisWorkbook.Close savechanges:=False Application.Quit End If This works the first time, but, if I open the workbook again, without having exited Excel, this code does not run and I get prompted by Excel about saving changes. Also, if the user makes a change and then tries to exit Excel, the workbook closes, but the application continues to run, forcing them to click 'exit' again. Thanks in advance for any help you can give. -- Bob Holmes |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Programmatically inserting a row with Excel 2003 | Excel Programming | |||
If a called sub exit, how to the caller exit right away? | Excel Programming | |||
Who can tell me how to programmatically insert an image into Excel by C#? | Excel Programming | |||
Subscribing programmatically from Excel via VBA | Excel Programming | |||
Excel VBA Programmatically delete a form? | Excel Programming |