View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen Per Jessen is offline
external usenet poster
 
Posts: 1,533
Default Problem protecting workbook

Hi

Nothing wrong with your code. You are protecting your workbook for
structure, ie user can not insert or delete sheets...

If you want to prevent users from changing data you need to protect each
sheet.

Regards,
Per

"Raj" skrev i meddelelsen
...
Hi,

I have the following code in Thisworkbook module:

Private Sub Workbook_Open()
UnprotectWorkbook
UnHideSheets
ProtectWorkbook
End Sub

Private Sub ProtectWorkbook()
ThisWorkbook.Protect Structu=True, Windows:=False, password:="xxxx"
'MsgBox ("Protected")
End Sub

Private Sub UnprotectWorkbook()
ThisWorkbook.Unprotect password:="xxxx"
End Sub

The Unhidesheets macros is from
http://www.cpearson.com/excel/EnableMacros.aspx

But despite the ProtectWorkbook line in the Workbook open event, the
Workbook is unprotected on opening. Am I doing something wrong. I
tried putting a message box in the Protecteworkbook (commented out
above). The message box pops up, indicating that processing has
reached that stage. But the workbook still remains unprotected on
opening.

Am I doing something wrong? Please help.

Thanks in advance.

Regards,
Raj