View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Damien McBain[_2_] Damien McBain[_2_] is offline
external usenet poster
 
Posts: 49
Default close excel without saving

Tom Ogilvy wrote:
in the ThisWorkbook module

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
cancel = True
End Sub

After you add the code, you will have to disable macros manually,
then save the workbook.


When I need to do this I create a sub called AdminSave which disables
events, saves, then enables events again and usually map Ctrl+Shift+S to run
it. This way I can save my changes but users changes won't be saved.
It's also handy if you're going to be using lots of on event code to make a
macro that toggles events and assign a keystroke combo to it.



"Mike" wrote in message
...
I have inserted various code(s) in vbs "this workbook" using
private sub auto_close
and private sub work_book close() after other code to close
excel/workbook without saving or displaying a prompt but none seems
to work.
I have used 'application.displayalerts = false'.' application.quit',
'thisworkbook.close savechanges:=false' etc etc in a variety of
different combinations.
Perhaps I am placing the code in the wrong place or perhaps I should
be saving before quitting or ..... ?
Can anyone help ?
Mike