Closing Excel without saving
It seems reasonble to close the workbook without saving if you want. But
closing the application seems kind of harsh to me.
If I have several other workbooks open and not saved (or that I don't want
closed), why should you close them?
But if you want...
If Response = vbNo Then
MsgBox "You will be logged out"
Application.DisplayAlerts = False
Application.Quit
'application.displayalerts = true
'thisworkbook.close savechanges:=false
Else
Range("b10.j10").Select
End if
Everything after the .quit (within that THEN portion) isn't necessary. If you
close excel, then the macro that used to be running ain't running anymore.
I wouldn't do this.
And if I did, I'd run away from that big guy who spent all morning working on an
important project and didn't save!
Abs wrote:
Hi
Attached is a procedure I wrote to close excel when a certain criteria was
not met. However I still get the default message box "Save changes". I want
the procedure to select the 'Don't Save' option and then Quit Excel. Any help
would be welcome.
Private Sub OptionButton6_Click()
Dim Response As String
Dim msg As String
Dim Style As String
msg = "Financial Support (Level 2 as in Studybank Guidelined) is not
available to you. Do you want to apply for Study Leave Only(Level One
Support)?"
Style = vbYesNo
Response = MsgBox(msg, Style)
If Response = vbNo Then
MsgBox "You will be logged out"
ActiveWorkbook.Close savechanges:=False
Application.Quit
Else
Range("b10.j10").Select
Endif
Endsub
--
Dave Peterson
|