Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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) ]
  #2   Report Post  
Posted to microsoft.public.excel.programming
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) ]


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to prompt for password to unprotect worksheets Sarah (OGI) Excel Programming 2 March 26th 08 09:58 AM
Macro giving errors at workbook open kcdonaldson Excel Discussion (Misc queries) 1 December 6th 05 04:15 PM
Macro to protect/unprotect with password Cam Excel Programming 3 July 26th 05 10:36 PM
Urgent ! how to unprotect VB macro password? starwil Excel Programming 1 May 15th 04 06:31 PM
unprotect more than one password in macro Morticcia Excel Programming 1 October 1st 03 04:55 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"