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


Hi folks,

I used the code below to protect a sheet:

ActiveSheet.EnableSelection = xlNoSelection
ActiveSheet.Protect Password:="CADEMP"

It works properly. I tested it after running the code.

But when I save the worksheet and reopen it I CAN select the cells. It
seems that the code was not effective.

But when I do the same procedure using the Excel menu
(Tolls/Protect/...) and save, when a reopen the woksheet it works
properly.

Do some of you know how to avoid the problem?

Thanks,
Marcelo Rychter


--
Marcelo Rychter
------------------------------------------------------------------------
Marcelo Rychter's Profile: http://www.excelforum.com/member.php...o&userid=35066
View this thread: http://www.excelforum.com/showthread...hreadid=557625

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sheet protection

Hi Marcelo,

The EnableSelection property is not persistent.

Try, therefo

'=============
Private Sub Workbook_Open()
Dim SH As Worksheet

Set SH = Me.Worksheets("Sheet1") '<<==== CHANGE

With SH
.EnableSelection = xlNoSelection
.Protect Password:="CADEMP"
End With

End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)

Select 'View Code' from the menu and paste the code.


---
Regards,
Norman


"Marcelo Rychter"
wrote in
message news:Marcelo.Rychter.2aan6z_1151802903.15@excelfor um-nospam.com...

Hi folks,

I used the code below to protect a sheet:

ActiveSheet.EnableSelection = xlNoSelection
ActiveSheet.Protect Password:="CADEMP"

It works properly. I tested it after running the code.

But when I save the worksheet and reopen it I CAN select the cells. It
seems that the code was not effective.

But when I do the same procedure using the Excel menu
(Tolls/Protect/...) and save, when a reopen the woksheet it works
properly.

Do some of you know how to avoid the problem?

Thanks,
Marcelo Rychter


--
Marcelo Rychter
------------------------------------------------------------------------
Marcelo Rychter's Profile:
http://www.excelforum.com/member.php...o&userid=35066
View this thread: http://www.excelforum.com/showthread...hreadid=557625



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
Excel Data Protection Best Practice: AKA: Real Sheet Protection Mushman(Woof!)[_2_] Excel Discussion (Misc queries) 4 December 30th 09 01:20 AM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
sheet protection Pa Maher Excel Worksheet Functions 1 April 8th 08 11:24 PM
Sheet protection error msg - Unrequested sheet activation deltree[_3_] Excel Programming 0 January 28th 04 06:20 PM
Sheet protection bug?? Dag Johansen[_5_] Excel Programming 1 October 14th 03 04:43 PM


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