aysam
Board Regular
- Joined
- Jun 24, 2009
- Messages
- 224
- Office Version
- 2010
- Platform
- Windows
Peace to you all
I have got this code
The code is to password protect and unprotect a workbook in one go.
When I enter a wrong password it gives an error message
I want it to show a vba message " Wrong Password " and goes on.
Thanks in advance
the code is :
I have got this code
The code is to password protect and unprotect a workbook in one go.
When I enter a wrong password it gives an error message
I want it to show a vba message " Wrong Password " and goes on.
Thanks in advance
the code is :
Code:
Private Sub CommandButton1_Click()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=TextBox1.Text
Else
wSheet.Protect Password:=TextBox1.Text
End If
Next wSheet
Unload Me
End Sub