Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing files without save
I am writing a macro which opens and closes a series of other workbooks.
When I close a workbook, Excel prompts me if I want to save the file and if I want to delete whatever is left on the clipboard. How can I, in VBA, close a workbook without saving it and not have Excel displaying a dialog box asking if I want to save? Also, how can I surpress the question about the clipboard, and automatically have Excel to discard those items left on the clipboard? Thanks in advance, Warren |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing files without save
Not sure about the clipboard thing but the save code is
here Workbooks("yourfilename.xls").Close savechanges:=False |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing files without save
Wrap you close code in
Application.DisplayAlerts = False Workbooks(1).Close Application.DisplayAlerts = True In article <H3nUb.226302$xy6.1158245@attbi_s02, "Warren" wrote: How can I, in VBA, close a workbook without saving it and not have Excel displaying a dialog box asking if I want to save? Also, how can I surpress the question about the clipboard, and automatically have Excel to discard those items left on the clipboard? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing files without save
Application.cutcopymode=false
Activeworkbook.close savechanges:=false -----Original Message----- I am writing a macro which opens and closes a series of other workbooks. When I close a workbook, Excel prompts me if I want to save the file and if I want to delete whatever is left on the clipboard. How can I, in VBA, close a workbook without saving it and not have Excel displaying a dialog box asking if I want to save? Also, how can I surpress the question about the clipboard, and automatically have Excel to discard those items left on the clipboard? Thanks in advance, Warren |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing files without save
Answered only the last part. For the first part, use the SaveChanges
argument: Workbooks(1).Close SaveChanges:=False In article , JE McGimpsey wrote: Wrap you close code in Application.DisplayAlerts = False Workbooks(1).Close Application.DisplayAlerts = True In article <H3nUb.226302$xy6.1158245@attbi_s02, "Warren" wrote: How can I, in VBA, close a workbook without saving it and not have Excel displaying a dialog box asking if I want to save? Also, how can I surpress the question about the clipboard, and automatically have Excel to discard those items left on the clipboard? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Closing files without save
A couple other things.
If wb.Saved = false then wb.Save i = 0 For Each wb In Workbooks If Not (wb.Name = "Personal.xls") Then i = i + 1 End If Next wb Application.EnableEvents = False Application.DisplayAlerts = False If i = 1 Then Application.Quit Else ThisWorkbook.Close (False) End if Application.EnableEvents = True Application.DisplayAlerts = True Set wb = Nothing Set ws = Nothing hth, Jim Feaver "Pete McCosh" wrote in message ... Application.cutcopymode=false Activeworkbook.close savechanges:=false -----Original Message----- I am writing a macro which opens and closes a series of other workbooks. When I close a workbook, Excel prompts me if I want to save the file and if I want to delete whatever is left on the clipboard. How can I, in VBA, close a workbook without saving it and not have Excel displaying a dialog box asking if I want to save? Also, how can I surpress the question about the clipboard, and automatically have Excel to discard those items left on the clipboard? Thanks in advance, Warren |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Closing but doesn't ask to save | Excel Discussion (Misc queries) | |||
Closing files and saving files | Excel Worksheet Functions | |||
Save files before closing | Excel Discussion (Misc queries) | |||
Closing the save changes box | Excel Programming | |||
Closing the save changes box | Excel Programming |