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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,215,331
Messages
6,124,312
Members
449,152
Latest member
PressEscape

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