Prevent Save as

luckycharm

Board Regular
Joined
Sep 3, 2003
Messages
88
This has been asked before (and answered), but somehow
does not work for me.

I put this code in 'this workbook':

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

I have also seen it with this alteration (inserted correctly):

' If SaveAsUI Then
' End If

1. If the user disables macros - it doesn't work?!
2. Whats the diferrence between the original code and the alteration?

Thanks.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This is an exercise in futility. Unless you can figure out how to stop someone from *every* other method of making a copy, both within XL and using other programs, why bother?
luckycharm said:
This has been asked before (and answered), but somehow
does not work for me.

I put this code in 'this workbook':

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

I have also seen it with this alteration (inserted correctly):

' If SaveAsUI Then
' End If

1. If the user disables macros - it doesn't work?!
2. Whats the diferrence between the original code and the alteration?

Thanks.
 
Upvote 0
Ok. I have taken some time to search around and agree with you.

Could you just enlighten me with answer to my 2nd. question?

Cheers.
 
Upvote 0
SaveAsUI returns whether the Save As dialog will be displayed.

Adding that code around the "Cancel=True" will prevent the user Saving As (but not regular saving).
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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