ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Do not propmt to save data on exit (https://www.excelbanter.com/excel-worksheet-functions/95874-do-not-propmt-save-data-exit.html)

Glenn Rathke \(Soft Design Consulting\)

Do not propmt to save data on exit
 
I'm reading/writing Excel data to SQL Server thru VBA. As such I do not
want to be prompted to save the data when closing down Excel. How can I do
this?


--
Thanks
Glenn



Paul Mathews

Do not propmt to save data on exit
 
Hi Glenn, try this:

Application.DisplayAlerts = False
Workbooks("YourWorkbook.xls").Close
Application.DisplayAlerts = True

If you want to immediately close right out of Excel then replace the second
line with Application.Quit.

"Glenn Rathke (Soft Design Consulting)" wrote:

I'm reading/writing Excel data to SQL Server thru VBA. As such I do not
want to be prompted to save the data when closing down Excel. How can I do
this?


--
Thanks
Glenn




Glenn Rathke \(Soft Design Consulting\)

Do not propmt to save data on exit
 
Thanks for the info but unfortunately it does not work or I am missing
something else.

If the user changes a cell in the spreadsheet, I do not want the message to
appear asking them if they want to save the file when closing the workbook.
Even with this code they user is prompted. Perhaps I implemented it
incorrectly, I placed it in the before close event.

Thanks
Glenn Rathke





"Glenn Rathke (Soft Design Consulting)"
wrote in message
...
I'm reading/writing Excel data to SQL Server thru VBA. As such I do not
want to be prompted to save the data when closing down Excel. How can I do
this?


--
Thanks
Glenn




Glenn Rathke \(Soft Design Consulting\)

This line of code does the trick
 
This line of code does the trick, I put it in the BeforeClose event.

ThisWorkbook.Saved = True

It tells the workbook that the most recent copy of the data has been saved
(in actuality it has not) and that it is not dirty. Now when the close event
is fired, the data does not appear that it has been changed.

Glenn


"Glenn Rathke (Soft Design Consulting)"
wrote in message
...
Thanks for the info but unfortunately it does not work or I am missing
something else.

If the user changes a cell in the spreadsheet, I do not want the message
to appear asking them if they want to save the file when closing the
workbook. Even with this code they user is prompted. Perhaps I
implemented it incorrectly, I placed it in the before close event.

Thanks
Glenn Rathke





"Glenn Rathke (Soft Design Consulting)"
wrote in message
...
I'm reading/writing Excel data to SQL Server thru VBA. As such I do not
want to be prompted to save the data when closing down Excel. How can I
do this?


--
Thanks
Glenn







All times are GMT +1. The time now is 09:21 PM.

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