ActiveWorkbook.Protect password:=range("rangename") does not work

I am trying to have macro protecting a workbook, with a password
specified by an administrator in one of the hidden worksheets.
The cell in the hidden worksheet in which the password is specified is
named, so I want to use the range name in the macro that
protects/unprotects the workbook.


It all works well when I try to unprotect the workbook, using the code
: ActiveWorkbook.Unprotect password:=range("rangename").
However, I get an error when I try to protect the workbook with the
code:  ActiveWorkbook.Protect password:=range("rangename")
The error message is: Runtime Error "1004, Application-defined or
Object-defined error.


Can anybody help ? 


Many Thanks 
Wim Ruepert 
Sydney, Australia

0
ruepert (2)
6/26/2005 7:45:37 AM
excel.misc 78881 articles. 5 followers. Follow

1 Replies
474 Views

Similar Articles

[PageSpeed] 11

the cell is not a password, but its content (the value) may be one:

try:

  range("rangename").value
0
6/26/2005 7:47:06 AM
Reply:

Similar Artilces:

Using rangename in relative reference
Say I have 12 months of data in 12 columns of one row. I'd like to create a rangename for the January data, use that rangename in a formula elsewhere, and then copy that formula to the 11 columns to the right. But I don't want to lock in the original rangename cell as an absolute reference when I copy it. Lotus 123 has this flexibility with rangenames, but it seems Excel does not. Am I just missing this feature somewhere? Art Hi Art, create your range name and the edit the refersto formula to remove the $ before the column reference. Charles ______________________ Decision...

CopyPicture method of range class failed using RangeName
All, I have a worksheet where I am cycling through some pivot tables and copying a range defined by a range name to an output sheet. The range being copied includes a chart and a few rows of cells. I keep getting a Run-Time Error '1004': CopyPicture method of range class failed I believe the syntax is correct because if I use error code and use resume it will continue after 0 to <15 tries? Anyone have any experience with this issue? I have tried both options below: Range(strRangeName).CopyPicture Appearance:=xlScreen, Format:=xlPicture Worksheets(SourceSheet...

How to epand size RangeName Box
Using either Excel 2000 or 2002 On Excel's standard menu bar, can the NameRange box be sized? If no, can a customized button that is sizable be written using Excell DLL call to the NameRange box object? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ Jay, You can do this with a few API calls. See www.cpearson.com/excel/NameBox.htm for details. -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com chip@cpearson.com "Jay_44" <Jay...

ActiveWorkbook.Protect password:=range("rangename") does not work
I am trying to have macro protecting a workbook, with a password specified by an administrator in one of the hidden worksheets. The cell in the hidden worksheet in which the password is specified is named, so I want to use the range name in the macro that protects/unprotects the workbook. It all works well when I try to unprotect the workbook, using the code : ActiveWorkbook.Unprotect password:=range("rangename"). However, I get an error when I try to protect the workbook with the code: ActiveWorkbook.Protect password:=range("rangename") The error message is: Runtime Err...