View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Olly[_3_] Olly[_3_] is offline
external usenet poster
 
Posts: 10
Default save on exit message box

Thanks that's what i needed

"Chip Pearson" wrote in message ...
Olly,

First of all, the line of code
ThisWorkbook.Saved = True
does NOT save the workbook. It tells Excel that the workbook does not need
to be saved, but does NOT actually save any changes.

Try something like the following:

Sub CloseSpreedsheet()
Dim Res As Long
Res = MsgBox("Do you want to save?", vbYesNoCancel)
Select Case Res
Case vbYes
ThisWorkbook.Save
Case vbNo
ThisWorkbook.Saved = True
Case vbCancel
Exit Sub
End Select
Application.Quit
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com