Quit Method

Applies To

Application Object.

Description

Quits Microsoft Excel. Does not run any Auto_Close macros before quitting.

Syntax

object.Quit

object

Required. The Application object.

Remarks

If unsaved workbooks are open when you use this method, Microsoft Excel displays a dialog box asking if you want to save the changes. You can prevent this by saving all workbooks before using the Quit method or by setting the DisplayAlerts property to False. When this property is False, Microsoft Excel does not display the dialog box when you quit with unsaved workbooks, and it quits without saving them.

If you set the Saved property for a workbook to True without saving it to the disk, Microsoft Excel will quit without asking you to save the workbook.

Example

This example saves all open workbooks and then closes Microsoft Excel.


For Each w In Application.Workbooks
    w.Save
Next w
Application.Quit