J JohnUK Mar 17, 2004 #1 Has anyone out there got a solution to protecting a Workbook/sheet with a password in VB and unprotecting again?
Has anyone out there got a solution to protecting a Workbook/sheet with a password in VB and unprotecting again?
H Harald Staff Mar 17, 2004 #3 Sub test() Dim Pwd As String Pwd = "Secret word" Sheets(1).Protect (Pwd) On Error Resume Next Sheets(1).Cells(1, 1).Value = 3 MsgBox Error On Error GoTo 0 Sheets(1).Unprotect (Pwd) ThisWorkbook.Protect (Pwd) On Error Resume Next Sheets(1).Delete MsgBox Error On Error GoTo 0 ThisWorkbook.Unprotect (Pwd) End Sub
Sub test() Dim Pwd As String Pwd = "Secret word" Sheets(1).Protect (Pwd) On Error Resume Next Sheets(1).Cells(1, 1).Value = 3 MsgBox Error On Error GoTo 0 Sheets(1).Unprotect (Pwd) ThisWorkbook.Protect (Pwd) On Error Resume Next Sheets(1).Delete MsgBox Error On Error GoTo 0 ThisWorkbook.Unprotect (Pwd) End Sub
H Harald Staff Mar 17, 2004 #5 Harald You are a star - Much appreciated John Click to expand... Thanks John. I needed something like that today. Best wishes Harald
Harald You are a star - Much appreciated John Click to expand... Thanks John. I needed something like that today. Best wishes Harald