Another "Object doesn't support..."
First, I'm not sure why you changed the workbook_sheetchange arguments from:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Second, I don't see where you declared sPwrd.
Is that in a General module like:
Public sPwrd as string
Third, check your typing.
Since the routine is behind the UserForm, I think I'd use code like:
sPwrd = me.tbPwrdEntry.Text
(Me is the object that owns the code--in this case, the userform.)
Are you sure tbPwrdEntry is really a textbox?
davegb wrote:
I have this code (still under development):
Private Sub Workbook_SheetChange(ByVal wsShName As Object, ByVal
Target As Range)
If Right(wsShName.Name, 7) < "Monthly" Then 'ignore these sheeets
Select Case wsShName.Name
Case "(Code Key)" 'Excluded sheets
Exit Sub
Case Else 'if password hasn't been entered yet, then ask
for password
If bPwrdEntrd = False Then
Call PasswordEntry
End If
End Select
End If
End Sub
Sub PasswordEntry()
Dim rFoundShName As Range
Dim rShNames As Range
Dim wsPwrdNames As Worksheet
'Dim sPwrd As String
Set wsPwrdNames = ThisWorkbook.Sheets("sheet1")
Set rShNames = wsPwrdNames.Range("A1:A8")
wsPwrdNames.Visible = True
ufPwrdEntry.Show
Set rFoundShName = rShNames.Find(ActiveSheet.Name, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If sPwrd = rFoundShName.Offset(1, 0).Value Then
bPwrdEntrd = True
End If
wsPwrdNames.Visible = False
End Sub
And this code in the userform:
Sub cbOK_Click()
sPwrd = ufPwrdEntry.tbPwrdEntry.Text <---- OBJECT DOESN'T SUPPORT
THIS....
If sPwrd = "" Then
MsgBox "Please enter the password to access this worksheet.",
vbOKCancel
End If
End Sub
I tried changing the .text to .value, but that didn't help.
Any ideas on why?
Thanks!
--
Dave Peterson
|