Save Changes:= False property not working

ks1987

New Member
Joined
Aug 8, 2012
Messages
24
Hi All,

I have written a code which uses the Save Changes: = False property of the Activeworkbook.close method. However, on running the code the user is being prompted to save the file.

The code snippet looks like this:

Code:
Dim w as workbook
Set w = workbooks.add
w.Close SaveChanges:=False

I have left out code which did not have relevance to the exercise (related to copying to and from workbooks)

Thanks,
ks1987
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try

Activeworkbook.Close False </pre>

Hi All,

I have written a code which uses the Save Changes: = False property of the Activeworkbook.close method. However, on running the code the user is being prompted to save the file.

The code snippet looks like this:

Code:
Dim w as workbook
Set w = workbooks.add
w.Close SaveChanges:=False

I have left out code which did not have relevance to the exercise (related to copying to and from workbooks)

Thanks,
ks1987
 
Upvote 0
You could try this (it does not actually save the workbook)

Code:
        Dim w As Workbook
        Set w = Workbooks.Add
        w.Saved = True
        w.Close SaveChanges:=False
 
Upvote 0
Wow! you're a wizard VoG.

Would you know, why in god's name wouldn't the first procedure work and this one works instead?
 
Upvote 0
This also worked for me.

I was opening workbooks that had event code in them, protected workbook and a hidden sheet that I was trying to get data off of.

So I opened the workbook, turned off application events, unprotected the workbook, un-hid the sheet, read the data into some variables, write that data to a different sheet,

THEN

Close without Save.

It kept popping up a "Save As" window.

Tried DisplayAlerts False - that didn't work.

So I set ActiveWorkbook.Saved = True as indicated above and for some reason it worked.

I'm still not sure I understand why but it did.


Thanks - hope this helps someone else.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top