View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
leonidas[_43_] leonidas[_43_] is offline
external usenet poster
 
Posts: 1
Default Quiting Excel program?


Hi Theuns,

Try this piece of VBA code. In the VB Editor you will find the folder
"Microsoft Excel Objects". Put this code in the object "ThisWorkbook"
and it should work fine!


Code:
--------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)

If Not Me.Saved Then
Msg = "Do you want to save the changes you made to "
Msg = Msg & Me.Name & "?"
Ans = MsgBox(Msg, vbQuestion + vbYesNoCancel)
Select Case Ans
Case vbYes
Me.Save
Case vbNo
Me.Saved = True
Case vbCancel
Cancel = True
Exit Sub
End Select
End If

End Sub
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=559216