macro to close file and not save changes

G

Guest

I have a "helper" file that opens, performs some tasks and then closes in a
macro, but before it closes, a pop up window appears and asks if I want to
save changes...I do not. Is there a code I can use so that that pop up
window does not appear or to automatically select "no"?
 
G

Guest

Assuming you are using the active workbook to reference you helper file then
this will do it

ActiveWorkbook.Close SaveChanges:=False

or otherwise

Workbooks("Whatever").Close SaveChanges:=False
 
G

Guest

Thanks Jim, that is what I was looking for...I also needed to ask on the
opening, it states that the file already exists, do you want to replace file,
I want to select yes. Do you know the code for that one?
 
G

Guest

I am a little lost with on the openeing and replace existing but you can try

Application.DisplayAlerts = false
'your code
Application.Displayalerts = true
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top