Cancel beforeSave

MimiTchoupie

New Member
Joined
Oct 25, 2022
Messages
3
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello,

I have a problem with my Private Sub BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) and it's driving me nuts ! I hope somebody will be able to help.

I had a code to cancel every save and it worked ! (th code down there)

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
End Sub

I had to disable it temporarily (by adding ' ) . What happened next is almost hyllarious : I reactivated it and, as the code is made for unabling the saves, I CAN'T SAVE MY CODE !

I'm desperate... please help me ! 🤯
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You can have it allow only you to save, for example:
VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Environ("UserName") <> "enter your userID here" Then Cancel = True
End Sub
 
Upvote 0
Solution
Thank you sooo so much ! It worked AND, I was able to use this function I didn't know for an other macro and it also work. Love this ! :love:
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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