Make impossible to save changes

Desu Nota from Columbus

Well-known Member
Joined
Mar 17, 2011
Messages
556
Is there a way through VBA to make a workbook impossible to save changes?

I need the workbook to be changeable, but the end result cannot be allowed to be saved. Is this possible?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try this in the ThisWorkbook module

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "You cannot save this workbook", vbExclamation
Cancel = True
End Sub
 
Upvote 0
I'm just curious...once you put something like VoG's suggestion in, how do you save your code so that it's in your sheet the next time you open it?
 
Upvote 0
Try this in the ThisWorkbook module

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "You cannot save this workbook", vbExclamation
Cancel = True
End Sub


How do I add this to the workbook and make it permanent (save it)?

Kind of a paradox, no?
 
Upvote 0
I'm just curious...once you put something like VoG's suggestion in, how do you save your code so that it's in your sheet the next time you open it?

Good point!

Press ALT + G to open the Immediate Window then enter

Application.EnableEvents=False

and press Enter

Then save the file.

Then use

Application.EnableEvents=True
 
Upvote 0
Thanks VoG! I helped someone a week or so back w/ a similar question but didn't think about your suggestion to save it. I'll have to tuck that away for future reference.
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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