PC Review


Reply
Thread Tools Rate Thread

Auto-Protect Sheet on Open and on Close

 
 
ryguy7272
Guest
Posts: n/a
 
      6th Oct 2009
I have the following code in ThisWorkbook:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ApplySecurity
End Sub

Private Sub Workbook_Open()
Call ApplySecurity
End Sub

I have this in a Module:
Sub ApplySecurity()
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlNoSelection
End Sub

I just noticed that whether macros are enabled or disabled, a user can just
click Tools > Protection > Unprotect and make any changes they want; Excel
doesn’t even ask me for a password. Did I miss something here?

Ryan--


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
 
Reply With Quote
 
 
 
 
Eduardo
Guest
Posts: n/a
 
      6th Oct 2009
Hi,
if you want your sheet to be protected use

Worksheets("your worksheet name").Protect Password:="your password"




"ryguy7272" wrote:

> I have the following code in ThisWorkbook:
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> Call ApplySecurity
> End Sub
>
> Private Sub Workbook_Open()
> Call ApplySecurity
> End Sub
>
> I have this in a Module:
> Sub ApplySecurity()
> ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
> ActiveSheet.EnableSelection = xlNoSelection
> End Sub
>
> I just noticed that whether macros are enabled or disabled, a user can just
> click Tools > Protection > Unprotect and make any changes they want; Excel
> doesn’t even ask me for a password. Did I miss something here?
>
> Ryan--
>
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
Luke M
Guest
Posts: n/a
 
      6th Oct 2009
As Eduardo mentions, you can setup a password. However, please note that it
is VERY easy to disable macros, or to simply use another macro (available
online) to crack a sheet protection password in 1 to 2 minutes. So, at best,
a sheet protection password provides a hindrance.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"ryguy7272" wrote:

> I have the following code in ThisWorkbook:
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> Call ApplySecurity
> End Sub
>
> Private Sub Workbook_Open()
> Call ApplySecurity
> End Sub
>
> I have this in a Module:
> Sub ApplySecurity()
> ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
> ActiveSheet.EnableSelection = xlNoSelection
> End Sub
>
> I just noticed that whether macros are enabled or disabled, a user can just
> click Tools > Protection > Unprotect and make any changes they want; Excel
> doesn’t even ask me for a password. Did I miss something here?
>
> Ryan--
>
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      6th Oct 2009
Yes, I am aware of the shortcomings.
Thanks, both of you.
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Luke M" wrote:

> As Eduardo mentions, you can setup a password. However, please note that it
> is VERY easy to disable macros, or to simply use another macro (available
> online) to crack a sheet protection password in 1 to 2 minutes. So, at best,
> a sheet protection password provides a hindrance.
> --
> Best Regards,
>
> Luke M
> *Remember to click "yes" if this post helped you!*
>
>
> "ryguy7272" wrote:
>
> > I have the following code in ThisWorkbook:
> > Private Sub Workbook_BeforeClose(Cancel As Boolean)
> > Call ApplySecurity
> > End Sub
> >
> > Private Sub Workbook_Open()
> > Call ApplySecurity
> > End Sub
> >
> > I have this in a Module:
> > Sub ApplySecurity()
> > ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
> > ActiveSheet.EnableSelection = xlNoSelection
> > End Sub
> >
> > I just noticed that whether macros are enabled or disabled, a user can just
> > click Tools > Protection > Unprotect and make any changes they want; Excel
> > doesn’t even ask me for a password. Did I miss something here?
> >
> > Ryan--
> >
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto-protect a sheet upon workbook close ryguy7272 Microsoft Excel Programming 4 7th Oct 2009 08:45 PM
how to setup a excel sheet to be protect after save and close file Marco Microsoft Excel Misc 0 11th Mar 2008 10:56 PM
cannot protect sheet with auto filter Dave Peterson Microsoft Excel Discussion 1 4th Oct 2006 05:48 PM
excel 2000 stays open for 5 seconds then auto close, empty sheet =?iso-8859-1?Q?Eberhard_M=FCcke_\=28MW-SOFT\=29?= Microsoft Excel Discussion 5 30th Jul 2004 11:56 PM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi Microsoft Excel Programming 1 2nd May 2004 03:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:02 AM.