Hi Friends, I want help to lock my excel workbook after a specific future date so that nobody can edit and copy only can read and required password in order to restore or unlock the workbook. Can somebody help for that?
Regards,
Hi Friends, I want help to lock my excel workbook after a specific future date so that nobody can edit and copy only can read and required password in order to restore or unlock the workbook. Can somebody help for that?
Regards,
You can create an open workbook event in the workbook module to protect the active sheet if a date is met, like this:
![]()
Option Explicit Private Sub Workbook_Open() Dim FutureLockDate As Date FutureLockDate = #11/3/2020# If Date >= FutureLockDate Then ThisWorkbook.Sheets("Sheet1").Protect Password:="123" End If End Sub
To protect the workbook:
![]()
Option Explicit Private Sub Workbook_Open() Dim FutureLockDate As Date FutureLockDate = #11/3/2020# If Date >= FutureLockDate Then ThisWorkbook.Protect Password:="123" End If End Sub
Hi its not working and also in this way i think workbook can be unprotected if somebody will disable the macro??
You can make sheets invisible (apart from maybe a 'warning' sheet) with something like this...
You can then make them visible in a workbook open event. This will ensure macros are enabled.![]()
Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.ScreenUpdating = False Sheets("Warning").Visible = xlSheetVisible ' hide all sheet but Warning sheet For Each sh In Worksheets If Not sh.Name = "Warning" Then sh.Visible = xlVeryHidden Next sh End Sub
BTW, if you tell me that "it's not working" without any 'added value' whatsoever, you will ensure you get no more help from me.![]()
Private Sub Workbook_Open() For Each sh In Worksheets sh.Visible = xlSheetVisible Next sh ' hide the warning sheet Sheets("Warning").Visible = xlVeryHidden End Sub
Last edited by Croweater; 11-04-2020 at 01:44 AM.
With available Excel protection methods, there is no full proof method of protecting Excel...Hi its not working and also in this way i think workbook can be unprotected if somebody will disable the macro??
Good Luck...
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
Also....Add a comment if you like!!!!
And remember...Mark Thread as Solved...
Excel Forum Rocks!!!
You can use VBA and event handlers to do this so that casual users wouldn't be able to use the workbook. However, there's no way to protect or lock any Excel workbook a user can open if that user is intent on breaking all the internal protections you try to impose. Only passwords for opening Excel workbooks are robust. All internal passwords and protections are weak and easily cracked by anyone with a web browser, a hexadecimal editor and the ability to follow instructions.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks