rorobear
11-01-2020, 12:19 AM
Hello Everyone,
Hoping someone can help me out with this. I’ve disabled the SAVE and SAVE AS in my workbook. When the user tries to save, they are given a YES or No option. If YES is selected a LOGIN Form appears asking for a username and password. Everything works up until this part. What I can’t figure out is how to make the workbook savable again after the username and password has been supplied. Also, once changes are made and the workbook is closed, the process should start over when it reopens. Below is the code and I’ve attached the workbook. The username is hazmat and the password is 1012. Any assistance is greatly appreciated.
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Ans As VbMsgBoxResult
Ans = MsgBox("You can't save this workbook!" & vbNewLine & _
"Do you have password to save the file?", vbQuestion + vbYesNo)
If Ans = vbYes Then
Frm_Login.Show 'UserForm to accept the password
End If
Cancel = True
End Sub
Hoping someone can help me out with this. I’ve disabled the SAVE and SAVE AS in my workbook. When the user tries to save, they are given a YES or No option. If YES is selected a LOGIN Form appears asking for a username and password. Everything works up until this part. What I can’t figure out is how to make the workbook savable again after the username and password has been supplied. Also, once changes are made and the workbook is closed, the process should start over when it reopens. Below is the code and I’ve attached the workbook. The username is hazmat and the password is 1012. Any assistance is greatly appreciated.
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Ans As VbMsgBoxResult
Ans = MsgBox("You can't save this workbook!" & vbNewLine & _
"Do you have password to save the file?", vbQuestion + vbYesNo)
If Ans = vbYes Then
Frm_Login.Show 'UserForm to accept the password
End If
Cancel = True
End Sub