View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default Using Activebook.Unprotect in macro giving errors (Password)

Hi

You need to insert the password in the unprotect statement:

Sub Show()
'
ActiveWorkbook.Unprotect Password:="Mypassword"

Sheets(2).Visible = True

End Sub

Regards,
Per



On 13 Jan., 17:06, Bricol wrote:
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) ]