workbook name change password

rickblunt

Active Member
Joined
Feb 18, 2008
Messages
474
Greetings, I have been using the following code to prevent users from changing the name of a workbook whenever they wanted to. Whenever I wanted to change it (because of a rev. 12 or 13a or something like that) I would just do it by changing the file name on my desktop. Not perfect or really secure I know, but it was easy and simple. There a few drawbacks of course with macro names having to be updated with each revision, or smart alecs changing it my way just to be funny. Is there some code (like a password prompt perhaps) that would allow me to change the name properly from within the app and perhaps even keep people from changing the name from the desktop? Thanks, RB

HTML:
Private Sub WorkBook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim lReply As Long
        If SaveAsUI = True Then
    lReply = MsgBox("Sorry, you are not allowed to save this workbook as a different name.  Do you wish to save it as it's orignal name?", vbQuestion + vbOKCancel)
    Cancel = (lReply = vbCancel)
    If Cancel = False Then Me.Save
        Cancel = True
    End If
End Sub
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

AlexM

Board Regular
Joined
Feb 14, 2007
Messages
132
I think there is no way to prevent customer from changing workbook name. It could be copied and renamed in Explorer, also if Application.EnableEvents = false, your macro will not be called.
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Give this a try
Code:
Private Sub WorkBook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If SaveAsUI = True Then
    rspn = InputBox("Enter Password to save")
        If rspn <> "password" Then
            MsgBox "Invalid Password"
            Cancel = True
        End If
    End If
End Sub

lenze
 

Watch MrExcel Video

Forum statistics

Threads
1,122,371
Messages
5,595,784
Members
414,020
Latest member
Meghdad

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
Top