![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 10:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com