Closing workbook w/o saving changes

starl

Administrator
Joined
Aug 16, 2002
Messages
5,984
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Have a workbook with a listbox, forms, macros, etc.
Even if you don't actually CHANGE anything, just by activating any of these, the workbook asks if you want to save it when closing.
How can I get around this prompt? I don't want to do an automatic save - what if the user did something and decided they didn't want to save... I just want it to wait for an actual CHANGE before asking

excel97
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

phantom1975

MrExcel MVP
Joined
Jun 3, 2002
Messages
3,962
You can create a macro in the Workbook_Close event:

Workbook.Saved = True

This won't actually save the workbook. It will just make Excel think that the workbook has been saved.


_________________
Pass on what you have learned. Support this great website by clicking on the sponsor's ads!.
This message was edited by phantom1975 on 2002-09-03 12:27
 

starl

Administrator
Joined
Aug 16, 2002
Messages
5,984
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
But if I do that, it won't prompt even if they actually DID make changes...
 

phantom1975

MrExcel MVP
Joined
Jun 3, 2002
Messages
3,962
You could do something like this:

Public Flag as Boolean
Private Sub Workbook_Open()
Flag = False
End Sub

Then you can create an IF statement when a legitimate change is made. For instance, if all of your variables are initialized to be "" or 0, then you can do this:

If variable1 <> "" Or variable1 <> 0 Then
Flag = True
End If

Then in the Workbook_Close event you can put this:

If Flag = False Then
Workbook.Saved = True
End If

Does this help?
 

starl

Administrator
Joined
Aug 16, 2002
Messages
5,984
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
yes, it does :biggrin:
thanks
 

Forum statistics

Threads
1,147,497
Messages
5,741,502
Members
423,662
Latest member
Ajmal Khursand

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
Top