Application.Quit doesn't work

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)    
    Dim sh As Worksheet
             
    Application.DisplayAlerts = False
    For Each sh In ThisWorkbook.Sheets
        Select Case sh.Name
            Case "Exhibit " & """I"" ", "page 2"
                Call deleteWS
        End Select
    Next
    Application.DisplayAlerts = True
    ThisWorkbook.Saved = True
    Application.ActiveWorkbook.Close
    Application.Quit
End Sub
This Code will do everything as expected except the last line.
Code:
Application.Quit
For whatever reason it won't shutdown/quit excel. It just closes the workbook.
I am running 2010 Office University version, if that helps. Thank You.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Once you close the workbook, you also close/stop any VBA procedures contained it that workbook.
So if this procedure is in that workbook, it will never get to that line of code.

If you just want to quit Excel, remove the "Application.ActiveWorkbook.Close" line. That will be unnecessary, as quitting the application will automatically close the workbook too.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top