Thread: SaveAsUI
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob van Gelder[_4_] Rob van Gelder[_4_] is offline
external usenet poster
 
Posts: 1,236
Default SaveAsUI

Gun,

Looks like you've got an extra End If where you don't need it.

Since you've got just two outcomes, vbYes or vbNo, why not replace Select
Case with a simple If statement?

eg.
Private Sub Workbook_BeforeClose(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If MsgBox("Do you want to save the expense report?", vbYesNo) = vbYes
Then ActiveWorkbook.SaveAs Else ActiveWorkbook.Close
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Gun_Maddie" wrote in message
...
Here is the code that I have written, for some reason I am unable to
get the Save As dialog box to appear, the spreadsheet just saves and
closes. Any suggestions?

Private Sub Workbook_BeforeClose(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

Msg = "Do you want to save the expense report?"
Ans = MsgBox(Msg, vbYesNo)
Select Case Ans
Case vbYes
ActiveWorkbook.SaveAs
Case vbNo
ActiveWorkbook.Close
End Select
End If

End Sub