![]() |
Close without saving
Hi everybody, I have the following code for closing the current workbook withou saving changes I want it to be developed to close all active workbooks Code ------------------- Private Sub Workbook_BeforeClose(Cancel As Boolean) ActiveWorkbook.Saved = True End Su ------------------- Thank you -- LoveCandl ----------------------------------------------------------------------- LoveCandle's Profile: http://www.excelforum.com/member.php...fo&userid=2861 View this thread: http://www.excelforum.com/showthread.php?threadid=55545 |
Close without saving
Hello Love Candle, Copy this code into a VBA module. You can call the macro anytime, and anywhere you need in your code. Code: -------------------- Public Sub CloseAllWorkbooks() Dim Wkb As Workbook For Each Wkb In Workbooks If Wkb.Name < ThisWorkbook.Name Then Wkb.Saved = True Wkb.Close End If Next Wkb With ThisWorkbook .Saved = True .Close End With End Sub -------------------- Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=555457 |
Close without saving
Thank you so much for this perfect code But, can you develop it more to close excel program completely not only the active workbooks windows only, -- LoveCandle ------------------------------------------------------------------------ LoveCandle's Profile: http://www.excelforum.com/member.php...o&userid=28612 View this thread: http://www.excelforum.com/showthread...hreadid=555457 |
Close without saving
Thank you soooooooo much for this perfect code -- LoveCandle ------------------------------------------------------------------------ LoveCandle's Profile: http://www.excelforum.com/member.php...o&userid=28612 View this thread: http://www.excelforum.com/showthread...hreadid=555457 |
All times are GMT +1. The time now is 12:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com