#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default 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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
countif function: how to distinguish case/make case sensitive mvwoolner Excel Worksheet Functions 3 March 18th 09 02:18 PM
change data of entire column from small case to upper case Ann Excel Worksheet Functions 1 August 16th 08 01:06 PM
Changing multiple cell text from lower case to upper case Patti Excel Discussion (Misc queries) 2 January 4th 08 08:35 PM
Change the text from lower case to upper case in an Excel work boo dave01968 Excel Discussion (Misc queries) 2 December 9th 05 09:09 AM
VBA- Calendar Control Click Event W Specific Select Case requirements Mark[_23_] Excel Programming 0 September 12th 03 06:24 PM


All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"