"Save" or "Save as" Only with password (?)

lazarovich

Board Regular
Joined
Feb 3, 2009
Messages
124
Hi,

I saw some treads with similar content but no one that I can use for my situation.

I would like to protect an excel file in the way that only users with the correct pasword (s) can "save" or "save as" the excel file.

In the case the user does not have the password or the authorized user enter an incorrect password they have the chance to ask for the correct password and then save it...otherwise the file must close without saving.

Thank you for your help.
Roberto.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Instead of password protecting the Save/Save As, why not restrict it on opening so that only those with the correct password can open the workbook in anything other than 'Read Only'?

HTH

Mel
 
Upvote 0
Something like this in the workbook's ThisWorkbook class module:

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Const sPASSWORD As String = "MrExcel"
    
    If Application.InputBox( _
            Prompt:="Please enter the password to save", _
            Title:="Password Required", _
            Type:=3) <> sPASSWORD Then
        
        MsgBox "You entered the wrong password. File NOT saved."
        Cancel = True
    End If
    
End Sub
 
Upvote 0
Thank you Colin....Is exactly what I need.

Mel, I know it sounds crazy but I want to allow some users to see the file, interact with it BUT not left any changes saved....that´s why I need a Save or Save As password.

Regards,
Roberto.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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