How to suppress "Do you want to save" dialog when closing a workbook in a Macro?

C

CW

Hello,

Say I have this code in a macro:

Application.ScreenUpdating = False
Dim wbBook1 As Workbook
Set wbBook1 = Workbooks.Open("C:\Book1.xls")
wbBook1.Close

If Book1.xls contains formulas, when this code executes, the dialog
box comes up asking "Do you want to save the changes you made..." with
the options Yes/No/Cancel. How can I make it so that dialog box
doesn't come up? If a button has to be chosen, preferably it would be
No, to save time when executing.

Any help would be greatly appreciated. Thanks!

-Mike
 
D

Dave Peterson

wbBook1.Close SaveChanges:=false

Use :=True when/if you want to save the changes.
 

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