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

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Coding deletion

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Coding deletion

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" wrote in
message ...
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
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
Row Deletion SiH23 Excel Programming 1 February 27th 09 07:04 PM
name deletion rk0909 Excel Discussion (Misc queries) 2 January 4th 08 11:03 PM
dup value deletion italiavb Excel Programming 0 February 6th 07 01:14 AM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM


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