Case Event

D

Daviv

I have the following code:
Case vbNo
FName = Application.GetSaveAsFilename(InitFileName,
"Excel File_ (*.xls),*.xls")
If FName <> False Then
ActiveWorkbook.SaveAs FName, CreateBackup = False
Else
Exit Sub
End If
Case vbYes
ThisWorkbook.Saved = True
Application.Quit
Case vbCancel
Cancel = True
Exit Sub

My question is: For case vbno, instead of saving the file and I cancel the
SaveAs, the application quits when I only want to exit the sub and return to
the worksheet.
 
V

Vergel Adriano

In what event is this code located in? Assuming it's on the
Workbook_BeforeClose event, add Cancel=True before calling exit sub. So,

Cancel=True
Exit Sub
 
B

Bob Phillips

Have you declared FName as type Variant

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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