B
Bricol
(Sorry if duplicated but network went down 1st time)
I have two pieces of code in workbook & cant see what I am doing wrong.
The first (seems to work) should hide a specific sheet & then protect the
workbook to stop unauthorised users from viewing
Sub Hide()
On Error Resume Next
Sheets(2).Select
ActiveWindow.SelectedSheets.Visible = False
ActiveWorkbook.Protect Structure:=True, Windows:=False,
Password:="Mypassword"
End Sub
The 2nd should allow a user who HAS PASSWORD to unprotect the workbook &
display the hidden sheet, but keeps aborting..
Sub Show()
'
ActiveWorkbook.Unprotect
Sheets(2).Visible = True
End Sub
Everytime I try to run it aborts and gives
"Run-time error '1004':
The password supplied is incorrect......"
(BUT I HAVEN'T EVEN BEEN PROMPTED FOR A PASSWORD!?)
What am I doing wrong? Thanks
Using Excel 2007, but wb is 2003 Compatible)
I have two pieces of code in workbook & cant see what I am doing wrong.
The first (seems to work) should hide a specific sheet & then protect the
workbook to stop unauthorised users from viewing
Sub Hide()
On Error Resume Next
Sheets(2).Select
ActiveWindow.SelectedSheets.Visible = False
ActiveWorkbook.Protect Structure:=True, Windows:=False,
Password:="Mypassword"
End Sub
The 2nd should allow a user who HAS PASSWORD to unprotect the workbook &
display the hidden sheet, but keeps aborting..
Sub Show()
'
ActiveWorkbook.Unprotect
Sheets(2).Visible = True
End Sub
Everytime I try to run it aborts and gives
"Run-time error '1004':
The password supplied is incorrect......"
(BUT I HAVEN'T EVEN BEEN PROMPTED FOR A PASSWORD!?)
What am I doing wrong? Thanks
Using Excel 2007, but wb is 2003 Compatible)