ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Case Event (https://www.excelbanter.com/excel-programming/384540-case-event.html)

Daviv

Case Event
 
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.
--
Thanks!

Vergel Adriano

Case Event
 
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



"Daviv" wrote:

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.
--
Thanks!


Bob Phillips

Case Event
 
Have you declared FName as type Variant

--
---
HTH

Bob

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



"Daviv" wrote in message
...
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.
--
Thanks!





All times are GMT +1. The time now is 04:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com