I have a Macro Enable Excel Document. I have using following code to protect the sheet. But the problem is that when i open the workbook, Dialog Box for unprotect password is appeared. After clicking cancel, it goes away. How can i get rid out of this.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Sheets("Summery Statement").Protect Password:="****"
Sheets("TR").Protect Password:="****"
ActiveWorkbook.Save
End Sub
Private Sub Workbook_Open()
If Sheets("Summery Statement").Unprotect = True Then
Sheets("Summery Statement").Protect Password:="****"
If Sheets("TR").Unprotect = True Then
Sheets("TR").Protect Password:="****"
If Err.Number <> 0 Then
MsgBox "The Password Provided is incorrect"
Exit Sub
End If
On Error GoTo 0
End If
End If
End Sub
Bookmarks