Thread: Case Select
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Coleman John Coleman is offline
external usenet poster
 
Posts: 274
Default Case Select

Is this in Workbook_BeforeClose ? If so, try

Case vbCancel
Cancel = True
Exit Sub

Hope that helps

-John Coleman


On Mar 2, 6:32 pm, Daviv wrote:
I have the following code:

InitFileName = Range("File").Value & Range("Project").Value & " " & "Insp._
Report," & " " & Format(Report(0, 1), "d-mmm-yy") & ".xls"
MsgResult = MsgBox("Have you saved the file?", vbYesNoCancel)
Select Case MsgResult
Case vbNo
FName = Application.GetSaveAsFilename(InitFileName,
"Excel File_(*.xls),*.xls")
ActiveWorkbook.SaveAs FName, CreateBackup = False
Cancel = True
Exit Sub
Case vbYes
ThisWorkbook.Saved = True
Application.Quit
Case vbCancel
Exit Sub
End Select
End Sub

When I select "cancel", the application quit instead of just exiting the sub
and going back to the worksheet.

Thanks!