I want to have a prompt box to pop up when closing a workbook to enter a password that sets the password to modify the workbook. I can get it to work if there is no password set, but once the password is already set it will not allow me to change it. Is this possible?
Thanks in advance.
Thanks in advance.
Code:
Sub PSWDForce()
Dim Passw As String
If MsgBox("Do you want to save the file before quitting?", vbYesNo, "Decisions, Decisions") = vbYes Then
Passw = InputBox("Set password to modify.", "Password to Modify Input")
Application.DisplayAlerts = False
ActiveWorkbook.WritePassword = Passw
ActiveWorkbook.Password = ""
ActiveWorkbook.Save
ActiveWorkbook.SaveAs writerespassword:=Passw, Password:=""
ActiveWorkbook.Save
Application.DisplayAlerts = True
End If
End Sub