Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
re Password Change again
Hi John
yes that was just a typo before. I've copied my code below the message I get is Method Unprotect of object worksheet failed. txtOld is the old password entered into a textbox on the form. Private Sub cmdChange_Click() If MsgBox("Changing passwords will result in the current data being lost" & vbNewLine & _ vbNewLine & "Do you want to continue?", vbYesNo) = vbYes Then Sheet1.unprotect PASSWORD:=Sheet3.Range("H65536").End (xlUp).Value ThisWorkbook.unprotect PASSWORD:=Sheet3.Range("E65536").End (xlUp).Value If optMan = True Then 'manager authorisation password Select Case txtOld.Text Case Sheet3.Range("b65536").End(xlUp).Value If TextBox1.Text < TextBox2.Text Then MsgBox "Passwords are not the same!" & vbNewLine & "Please try again", vbCritical TextBox1 = "" TextBox2 = "" TextBox1.SetFocus Else Sheet3.Range("b65536").End(xlUp).Value = TextBox1.Text Call save End If Case Else MsgBox "Invalid Password", vbCritical txtOld = "" txtOld.SetFocus End Select ElseIf optWB = True Then 'workbook password Select Case txtOld.Text Case Sheet3.Range("e65536").End(xlUp).Value If TextBox1.Text < TextBox2.Text Then MsgBox "Passwords are not the same!" & vbNewLine & "Please try again", vbCritical TextBox1 = "" TextBox2 = "" TextBox1.SetFocus Else Sheet3.Range("e65536").End(xlUp).Value = TextBox1.Text Call save End If Case Else MsgBox "Invalid Password", vbCritical txtOld = "" txtOld.SetFocus End Select ElseIf optWS = True Then Select Case txtOld.Text Case Sheet3.Range("h65536").End(xlUp).Value If TextBox1.Text < TextBox2.Text Then MsgBox "Passwords are not the same!" & vbNewLine & "Please try again", vbCritical TextBox1 = "" TextBox2 = "" TextBox1.SetFocus Else Sheet1.unprotect PASSWORD:=txtOld.Text Sheet3.Range("h65536").End(xlUp).Value = TextBox1.Text Call save Unload Me End If Case Else MsgBox "Invalid Password", vbCritical txtOld = "" txtOld.SetFocus End Select End If End If End Sub Sub save() With Sheet1 .Range ("C16,D2:F2,D6:F6,D8:F8,D18:G21,F24:F28").ClearCon tents .TextBox1.Enabled = True .TextBox2.Enabled = True .txtSpecify.Enabled = True .TextBox1 = "" .TextBox2 = "" .txtSpecify = "" .TextBox1.Enabled = False .TextBox2.Enabled = False .txtSpecify.Enabled = False .cmdChange.Enabled = False .CommandButton1.BackColor = vbRed .CommandButton1.Caption = "Ï" End With ThisWorkbook.save ThisWorkbook.Protect PASSWORD:=Sheet3.Range("e65536").End (xlUp).Value, structu=True Sheet1.Protect PASSWORD:=Sheet3.Range("h65536").End (xlUp).Value, USERINTERFACEONLY:=True End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
re Password Change again
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change Workbook Password | Excel Worksheet Functions | |||
EXCEL CHANGE PASSWORD | Excel Discussion (Misc queries) | |||
Change password | Excel Discussion (Misc queries) | |||
password change again | Excel Programming | |||
change password | Excel Programming |