ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programatically close a file without saving (https://www.excelbanter.com/excel-programming/319590-programatically-close-file-without-saving.html)

[email protected]

Programatically close a file without saving
 
Hello:
I need to be able to close a file programmatically, but when I try to
do so the Excel message: "Do you want to save the changes that you made
to ---" With the choices "Yes", "No" and "Cancel" comes off & I would
like to close the file without saving it.
I would appreciate help wit the above.

TIA
Vinay


Gord Dibben

Programatically close a file without saving
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

Gord Dibben Excel MVP

On 25 Dec 2004 15:23:16 -0800, wrote:

Hello:
I need to be able to close a file programmatically, but when I try to
do so the Excel message: "Do you want to save the changes that you made
to ---" With the choices "Yes", "No" and "Cancel" comes off & I would
like to close the file without saving it.
I would appreciate help wit the above.

TIA
Vinay



KL[_6_]

Programatically close a file without saving
 
You could also use one of these:

ThisWorkbook.Close SaveChanges:=False

or

Application.DisplayAlerts = False

Regards,
KL

"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

Gord Dibben Excel MVP

On 25 Dec 2004 15:23:16 -0800, wrote:

Hello:
I need to be able to close a file programmatically, but when I try to
do so the Excel message: "Do you want to save the changes that you made
to ---" With the choices "Yes", "No" and "Cancel" comes off & I would
like to close the file without saving it.
I would appreciate help wit the above.

TIA
Vinay






All times are GMT +1. The time now is 05:33 PM.

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