I do not have your thread here (or there) locked. I am not an administrator/moderator to this board and I really do not know how to read a password from a text file.
Since Excel is not an entirely secure application anybody with some know-how can crack into your spreadsheet. I see you were initially using a password from a sheet, but then you requested to read a passord from a text file.
My suggestion would be to hard code your password into the VBA and then password protect your project.
The code below worked for me.
Hope this satisfies your needs...if not please let us know
Private Sub Workbook_Open()
'ThisWokbook Module
UserForm1.Show
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'ThisWokbook Module
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Sheet1" Then
ws.Visible = False
ws.Protect Password:="password"
End If
Next ws
Sheets("Sheet1").Protect Password:="password"
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton1_Click()
'UserForm Code
Dim ws As Worksheet
Dim MyPassword As String
MyPassword = TextBox1.Text
If Sheet1.ProtectContents = True And TextBox1.Text = "password" Then
For Each ws In ActiveWorkbook.Worksheets
ws.Visible = True
ws.Unprotect Password:=MyPassword
Next ws
End If
Call ParseText
MsgBox ("Called ParseText")
Unload Me
End Sub
Bookmarks