Closing workbook w/o saving changes

starl

Administrator
Joined
Aug 16, 2002
Messages
6,082
Office Version
  1. 365
Platform
  1. Windows
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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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
 
Upvote 0
But if I do that, it won't prompt even if they actually DID make changes...
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,218,576
Messages
6,143,315
Members
450,477
Latest member
teresab543

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