View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Eric Fingerhut[_3_] Eric Fingerhut[_3_] is offline
external usenet poster
 
Posts: 6
Default Saving VBA project on workbook close

Sorry if this is an obvious one. I want to have code to protect myself from
closing a project without saving changes. The code below just doesn't execute
the save although the logic hits the line.

TIA, Eric

in Thisworkbook

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = Not Shutdown(ThisWorkbook)
If Cancel Then
Call ThisWorkbook.Save
Debug.Assert ThisWorkbook.Saved
Cancel = False
End If
End Sub