View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bricol Bricol is offline
external usenet poster
 
Posts: 10
Default Using Activebook.Unprotect in macro giving errors (Password)

I have scoured net for answer without success, & hope someone here can help.

I have two procedures in my file
The first Hides a specific sheet & then protects the workbook WITH A
PASSWORD to prevent user from displaying - seems to work fine...

Sub Hide()
On Error Resume Next
Sheets(2).Select
ActiveWindow.SelectedSheets.Visible = False
ActiveWorkbook.Protect Structu=True, Windows:=False,
Password:="Mypassword"
End Sub

The 2nd should allow a user who has the password to unprotect & view the
sheet, but it doesnt work!

Sub Show()
'
ActiveWorkbook.Unprotect

Sheets(2).Visible = True

End Sub

Every time I try & run 2nd macro it stops with a
"Run-time error '1004':
The password you supplied is not correct....."
BUT IT ISN'T PROMPTING ME TO SUPPLY A PASSWORD!?

What am I doing wrong?

[Using Excel 2007 (but workbook is 2003 Compatible) ]