Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Problem protecting workbook

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Problem protecting workbook

On Jun 30, 4:39*pm, "Per Jessen" wrote:
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 ...



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- Hide quoted text -


- Show quoted text -


Hi Per,

Thanks for the input. I have already protected the sheets. My
requirement is that sheets should not be deleted. I am afraid that the
user may delete the worksheets in case the workbook is not protected.
Hence the code for protecting the workbook. But, the issue is why is
the workbook protection not happening despite the code?

Regards,
Raj
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Problem protecting workbook


Hi Per,

Thanks for the input. I have already protected the sheets. My
requirement is that sheets should not be deleted. I am afraid that the
user may delete the worksheets in case the workbook is not protected.
Hence the code for protecting the workbook. But, the issue is why is
the workbook protection not happening despite the code?

Regards,
Raj


Hi Raj

Your code works fine here in excel 2000 & 2007. I closed the workbook
without protection. Once i opened it again. it was protected. If I right
click on a sheet tab the options "Insert", "Delete" etc. is grayed out.

Regards,
Per

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Problem protecting workbook

On Jul 1, 6:25*pm, "Per Jessen" wrote:
Hi Per,


Thanks for the input. I have already protected the sheets. My
requirement is that sheets should not be deleted. I am afraid that the
user may delete the worksheets in case the workbook is not protected.
Hence the code for protecting the workbook. But, the issue is why is
the workbook protection not happening despite the code?


Regards,
Raj


Hi Raj

Your code works fine here in excel 2000 & 2007. I closed the workbook
without protection. Once i opened it again. it was protected. If I right
click on a sheet tab the options "Insert", "Delete" etc. is grayed out.

Regards,
Per


Hi Per,

Thanks for the trouble you have taken. Your assertion about the code,
made me think further. I was wrong. I was wrongly assuming that the
icon under "Review" tab in Excel 2007 would change to "Unprotect
Workbook" when the workbook is protected similar to the "Unprotect
Sheet" that happens when a Sheet is protected.

Regards,
Raj


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
Protecting a workbook Kim Excel Worksheet Functions 5 September 29th 08 06:26 PM
protecting workbook jolowe Excel Discussion (Misc queries) 2 June 8th 08 02:57 PM
Problem protecting cells in a mult-page workbook Arsenio Oloroso Excel Discussion (Misc queries) 2 September 5th 06 02:34 PM
Protecting Workbook!.. Neo1 Excel Worksheet Functions 3 May 3rd 06 01:22 PM
Protecting Workbook Paul Cooling Excel Discussion (Misc queries) 2 March 7th 05 11:55 AM


All times are GMT +1. The time now is 04:49 PM.

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

About Us

"It's about Microsoft Excel"