Yes, it can be done. Put this code in the workbook (change the password as required):
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Password As String
Dim EnteredPassword As String
Password = "Barrie"
EnteredPassword = InputBox("Enter password to save changes")
If EnteredPassword <> Password Then Cancel = True
End Sub
If you need any help implementing this just let me know.
Regards,
Barrie
Barrie Davidson
An improvement to my code
This would be better (includes a message that the file was not saved if incorrect password supplied).
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Password As String
Dim EnteredPassword As String
Password = "Barrie"
EnteredPassword = InputBox("Enter password to save changes")
If EnteredPassword <> Password Then
Cancel = True
MsgBox ("Password incorrect, file not saved")
End If
End Sub
Barrie Davidson
Re: An improvement to my code
That is exactly what I needed!
Thanks alot.
Mav