Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Activebook.Unprotect in macro giving errors (Pwd)#2

(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 Structu=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)
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
Using Activebook.Unprotect in macro giving errors (Password) Bricol Excel Programming 1 January 13th 10 04:12 PM
Range().resize giving errors Harry Tuttle Excel Programming 2 December 28th 05 06:29 PM
Range().resize giving errors Harry Tuttle Excel Programming 0 December 27th 05 07:24 PM
Range().resize giving errors Harry Tuttle Excel Programming 0 December 27th 05 07:04 PM
Macro giving errors at workbook open kcdonaldson Excel Discussion (Misc queries) 1 December 6th 05 04:15 PM


All times are GMT +1. The time now is 03:39 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"