Add a call to ActiveWorkbook.Close
to ExitWithoutPrompt
:
Sub ExitWithoutPrompt()
MsgBox "You failed to select a file, therefore Excel will now close. Please refer to the readme file."
Excel.Application.DisplayAlerts = False
Excel.Application.Quit
ActiveWorkbook.Close False
End Sub
This works for me under Excel 2003.
For some reason, the order of calling Application.Quit
and ActiveWorkbook.Close
is important. Counter-intuitively, at least to me, if you call ActiveWorkbook.Close
before Application.Quit
you still get the error.
Patrick Cuff
2008-12-30 19:43:01