Case Select

D

Daviv

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!
 
J

John Coleman

Is this in Workbook_BeforeClose ? If so, try

Case vbCancel
Cancel = True
Exit Sub

Hope that helps

-John Coleman
 
D

Daviv

Thanks a million!
--
Thanks!


John Coleman said:
Is this in Workbook_BeforeClose ? If so, try

Case vbCancel
Cancel = True
Exit Sub

Hope that helps

-John Coleman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top