PC Review


Reply
Thread Tools Rate Thread

Coding deletion

 
 
Hamed parhizkar
Guest
Posts: n/a
 
      23rd Nov 2009
Currently I have a vba code that will eliminate the page after it has been
opened a number of times. For instacne if the code is set to 3, after the 3rd
time the sheet is opened it will lock the user out permanently. However, if
they should to select disable macros, they can access the sheet. How can you
lock them out permanently. below is the code I am using.

Private Sub Workbook_Open()
Dim OpenCount As Integer
OpenCount = GetSetting("MyApp", "Count", "OpenCount", 0)

SaveSetting "MyApp", "Count", "OpenCount", OpenCount + 1

If OpenCount >= 3 Then ThisWorkbook.Close SaveChanges:=False

End Sub



 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      23rd Nov 2009
How can you lock them out permanently.

You can't. Excel security isn't robust enough to do what you want. You can
make things more difficult by; for example, making every sheet except a blank
one XlVeryHidden but this will only deter the inexperienced.

Mike


"Hamed parhizkar" wrote:

> Currently I have a vba code that will eliminate the page after it has been
> opened a number of times. For instacne if the code is set to 3, after the 3rd
> time the sheet is opened it will lock the user out permanently. However, if
> they should to select disable macros, they can access the sheet. How can you
> lock them out permanently. below is the code I am using.
>
> Private Sub Workbook_Open()
> Dim OpenCount As Integer
> OpenCount = GetSetting("MyApp", "Count", "OpenCount", 0)
>
> SaveSetting "MyApp", "Count", "OpenCount", OpenCount + 1
>
> If OpenCount >= 3 Then ThisWorkbook.Close SaveChanges:=False
>
> End Sub
>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      23rd Nov 2009
Include a cover page that says something like "this workbook cannot be used
if macros are disabled"

In the BeforeSave event,
- abort save (Cancel = true)
- disable screenupdating
- disable events
- hide all sheets but unhide the cover page
- with code save the workbook (Thisworkbook.save)
- Unhide all sheets and hide the cover page
- reset the "dirty" flag, ThisWorkbook.Saved = True
- Re-enable events and screenupdating

In the Open event unhide all sheets and hide the cover page (with
screenupdating temporarily disabled) and again reset the "dirty" flag,
ThisWorkbook.Saved = True

Lock and password protect the project.

Regards,
Peter T


"Hamed parhizkar" <(E-Mail Removed)> wrote in
message news:EADDA96B-E65A-4BA1-AB99-(E-Mail Removed)...
> Currently I have a vba code that will eliminate the page after it has been
> opened a number of times. For instacne if the code is set to 3, after the
> 3rd
> time the sheet is opened it will lock the user out permanently. However,
> if
> they should to select disable macros, they can access the sheet. How can
> you
> lock them out permanently. below is the code I am using.
>
> Private Sub Workbook_Open()
> Dim OpenCount As Integer
> OpenCount = GetSetting("MyApp", "Count", "OpenCount", 0)
>
> SaveSetting "MyApp", "Count", "OpenCount", OpenCount + 1
>
> If OpenCount >= 3 Then ThisWorkbook.Close SaveChanges:=False
>
> End Sub
>
>
>



 
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
Disable Deletion/Not allow Deletion =?Utf-8?B?U3RvY2t3ZWxsNDM=?= Microsoft Access Form Coding 15 14th Feb 2007 05:16 PM
Should I do this deletion?? MZB Windows XP Help 1 31st Mar 2006 06:34 AM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan Microsoft Excel Programming 10 6th Oct 2005 01:18 PM
Problems with coding and coding question!! James Microsoft Access Form Coding 0 23rd Feb 2004 10:34 AM
Please help with row deletion bkbri Microsoft Excel Misc 1 14th Dec 2003 03:55 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:34 AM.