Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default re Password Change again

Libby,

Please try to continue in the same thread and not start a new one.
It helps others (who may be able to help you) follow what's
transpired to get you to your goal.

If possible, can you send the workbook directly to me and
I'll take a look at it.


John


"Libby" wrote in message
...
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Workbook Password iperlovsky Excel Worksheet Functions 3 July 3rd 08 06:08 PM
EXCEL CHANGE PASSWORD Mike Christie Excel Discussion (Misc queries) 2 December 14th 06 05:16 PM
Change password Anthony G of La Quinta Excel Discussion (Misc queries) 1 June 21st 05 12:58 AM
password change again Libby Excel Programming 3 December 21st 03 11:02 PM
change password Libby Excel Programming 1 December 20th 03 09:33 PM


All times are GMT +1. The time now is 10:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"