ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Completely Exit Excel Macro (https://www.excelbanter.com/excel-discussion-misc-queries/150012-completely-exit-excel-macro.html)

Rob

Completely Exit Excel Macro
 
How do I get Excel to actually completely exit? Below is the code I'm trying
to use but when it gets to the close portion, it only closes the workbook and
Excel is still running/opened.

DoFinishing = MsgBox("All Done With Updates... Save Spreadsheet and
Exit?", vbYesNo)
If DoFinishing = vbNo Then
DoSave = MsgBox("Then Do You Want To Save The Spreadsheet?", vbYesNo)
If DoSave = vbNo Then
Exit Sub
Else
Application.DisplayAlerts = False
Application.Workbooks("! Compiled.xls").Save
Application.DisplayAlerts = True
Exit Sub
End If
Else
Application.DisplayAlerts = False
Application.Workbooks("! Compiled.xls").Save
Application.Workbooks("! Compiled.xls").Close
Application.DisplayAlerts = True
End If

Thanks,
R

Pete_UK

Completely Exit Excel Macro
 
Try:

Application.Quit

at the very end.

Hope this helps.

Pete

On Jul 12, 11:16 pm, Rob wrote:
How do I get Excel to actually completely exit? Below is the code I'm trying
to use but when it gets to the close portion, it only closes the workbook and
Excel is still running/opened.

DoFinishing = MsgBox("All Done With Updates... Save Spreadsheet and
Exit?", vbYesNo)
If DoFinishing = vbNo Then
DoSave = MsgBox("Then Do You Want To Save The Spreadsheet?", vbYesNo)
If DoSave = vbNo Then
Exit Sub
Else
Application.DisplayAlerts = False
Application.Workbooks("! Compiled.xls").Save
Application.DisplayAlerts = True
Exit Sub
End If
Else
Application.DisplayAlerts = False
Application.Workbooks("! Compiled.xls").Save
Application.Workbooks("! Compiled.xls").Close
Application.DisplayAlerts = True
End If

Thanks,
R




Rob

Completely Exit Excel Macro
 
Absolutely Wonderful. So simple I feel stupid.

Thanks Much,
R



"Pete_UK" wrote:

Try:

Application.Quit

at the very end.

Hope this helps.

Pete

On Jul 12, 11:16 pm, Rob wrote:
How do I get Excel to actually completely exit? Below is the code I'm trying
to use but when it gets to the close portion, it only closes the workbook and
Excel is still running/opened.

DoFinishing = MsgBox("All Done With Updates... Save Spreadsheet and
Exit?", vbYesNo)
If DoFinishing = vbNo Then
DoSave = MsgBox("Then Do You Want To Save The Spreadsheet?", vbYesNo)
If DoSave = vbNo Then
Exit Sub
Else
Application.DisplayAlerts = False
Application.Workbooks("! Compiled.xls").Save
Application.DisplayAlerts = True
Exit Sub
End If
Else
Application.DisplayAlerts = False
Application.Workbooks("! Compiled.xls").Save
Application.Workbooks("! Compiled.xls").Close
Application.DisplayAlerts = True
End If

Thanks,
R





Pete_UK

Completely Exit Excel Macro
 
You're welcome - thanks for feeding back.

Pete

On Jul 13, 12:32 pm, Rob wrote:
Absolutely Wonderful. So simple I feel stupid.

Thanks Much,
R



"Pete_UK" wrote:
Try:


Application.Quit


at the very end.


Hope this helps.


Pete


On Jul 12, 11:16 pm, Rob wrote:
How do I get Excel to actually completely exit? Below is the code I'm trying
to use but when it gets to the close portion, it only closes the workbook and
Excel is still running/opened.


DoFinishing = MsgBox("All Done With Updates... Save Spreadsheet and
Exit?", vbYesNo)
If DoFinishing = vbNo Then
DoSave = MsgBox("Then Do You Want To Save The Spreadsheet?", vbYesNo)
If DoSave = vbNo Then
Exit Sub
Else
Application.DisplayAlerts = False
Application.Workbooks("! Compiled.xls").Save
Application.DisplayAlerts = True
Exit Sub
End If
Else
Application.DisplayAlerts = False
Application.Workbooks("! Compiled.xls").Save
Application.Workbooks("! Compiled.xls").Close
Application.DisplayAlerts = True
End If


Thanks,
R- Hide quoted text -


- Show quoted text -





All times are GMT +1. The time now is 04:29 AM.

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