View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ??

Hi Wim,

The syntax for the Protect method includes a Password argument and, as it
relates to the workbook object includes two additional arguments: Structure
and Windows. All of the arguments are optional. The default values for the
Structure and Windows arguments is False. In consequence, your instruction:

ActiveWorkbook.Protect Password:=Range("adminpassword").Value


is an instuction to Excel not to protect either Windows or Structure. As
there is nothing left to protect, Excel treats your instruction as an
unprotect request.

Try manually protecting the workbbook with both the Windows and structure
options unchecked and, even with a password, the OK confirmation button
becomes unavailable.

---
Regards,
Norman



"WimR" wrote in message
oups.com...
My code in the workook_open() macro includes the following to ensure
the workbook is protected at all times.

ActiveWorkbook.Protect Password:=Range("adminpassword").Value

When this code runs while the workbook IS protected, it actually causes
the workbook to be UNPROTECTED.

How strange is this ??!!

Does anybody know why this happens and how I can prevent this from
happening.

I am running Excel 2003

thank you very much for your help.

Wim