Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Closing files without save

Not sure about the clipboard thing but the save code is
here

Workbooks("yourfilename.xls").Close savechanges:=False
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing but doesn't ask to save TJAC Excel Discussion (Misc queries) 1 November 2nd 06 09:31 PM
Closing files and saving files dan Excel Worksheet Functions 0 August 15th 06 04:07 AM
Save files before closing MasterP Excel Discussion (Misc queries) 1 December 30th 05 08:13 PM
Closing the save changes box John Tjia Excel Programming 0 January 9th 04 09:54 PM
Closing the save changes box John Wilson Excel Programming 0 January 9th 04 04:13 PM


All times are GMT +1. The time now is 01:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"