Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Close Workbook Without Save Any Changes Made
How to make macro to close a workbook without save any changes that made before the function CLOSE. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Close Workbook Without Save Any Changes Made
first you can open the workbook in readonly mode to make sure no changes are made to the workbook. Second when you save the workbook use set bk = workbooks.open(filename:="book1.xls") 'your code here bk.close savechanges:=False "Tyven Bong" wrote: How to make macro to close a workbook without save any changes that made before the function CLOSE. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Close Workbook Without Save Any Changes Made
From VBA help: Remarks Closing a workbook from Visual Basic doesn't run any Auto_Close macros in the workbook. Use the RunAutoMacros method to run the auto close macros. Example This example closes Book1.xls and discards any changes that have been made to it. Workbooks("BOOK1.XLS").Close SaveChanges:=False -- Steve "Tyven Bong" <Tyven wrote in message ... How to make macro to close a workbook without save any changes that made before the function CLOSE. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Close Workbook Without Save Any Changes Made
Or kill the lot Sub QitNoSave() Application.DisplayAlerts = False Application.Quit 'closes Excel End Sub -- Steve "AltaEgo" <Somewhere@NotHere wrote in message ... From VBA help: Remarks Closing a workbook from Visual Basic doesn't run any Auto_Close macros in the workbook. Use the RunAutoMacros method to run the auto close macros. Example This example closes Book1.xls and discards any changes that have been made to it. Workbooks("BOOK1.XLS").Close SaveChanges:=False -- Steve "Tyven Bong" <Tyven wrote in message ... How to make macro to close a workbook without save any changes that made before the function CLOSE. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to Close Workbook Without Save Any Changes Made
the application asks if you want to save if there have been any changes. WB.Close False is the easiest way to overcome this - where wb is the workbook obkect set to the workbook we're dealing with. Also , we could clear the dirty flag which tells excel whether the sheets have changed or not in the ThisWorkbook's before close event. A value of False would trigger the application alert to save. Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Saved = True End Sub "Tyven Bong" <Tyven wrote in message ... How to make macro to close a workbook without save any changes that made before the function CLOSE. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Close workbook without being prompted to save in VBA | Excel Programming | |||
Open New Workbook / Save and Close Current Workbook | Excel Programming | |||
Save Changes Prompt before Close, when no changes were made | Excel Programming | |||
Help on Workbook close and workbook save events | Excel Programming | |||
i made change in a current workbook and accidentally save it, can. | Excel Discussion (Misc queries) |