Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

close excell without getting the message asking to save

Status
Not open for further replies.

Fursten

Programmer
Dec 27, 2000
403
PT
Hi,

I´m changing an excell file programatically... If I close the object programatically I will get a message box asking if I want to save changes.

I would like to program the file so if I make a change and not want to save it, I will cancel what I have done and this way I will not get that massage asking to save the file...

Thank you

Sérgio Oliveira
 
check out the .Saved property of the WorkBook object
set this to true before closing then Excel won't ask you if you want to save changes
 
Not too sure if this is exactly what you want but if you use this code,

Application.DisplayAlerts = False

this will ignore the message box BUT it will save the file.
 
Passing "XlSaveAction.xlDoNotSaveChanges" as the parameter for the "Close" method works for me.
Example:

Public Sub CloseMyWorkbook()
ActiveWorkbook.Close SaveChanges:=XlSaveAction.xlDoNotSaveChanges
End Sub


Hope this helps,
Pete
 
another, nice and easy approach is

Code:
xlBook.Close savechanges:=False
Mark Saunders :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top