Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I code a "self-destruct" triggered after a certain date?
I am responsible for distributing a business-sensitive
worksheet and wish to enable the spreadsheet to become inoperable after a certain date. A long time ago, I recall that it was possible to install a "time bomb" in the spreadsheet, that was a macro which after a certain date deleted lots of pages in the worksheet and then saved itself onto the existing file name. That way, after a certain date, anyone trying to open the file would see the file render itself useless. I do not know how that can be done in recent versions of Excel (2000, 2003). Any suggestions would be much appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I code a "self-destruct" triggered after a certain date?
If you can protect the workbook, insert a new worksheet,
enter in your self-destruct date and then hide that sheet. Protect the workbook. Add VB code to "Workbook_BeforeClose" subroutine to check for the date being greater than your self-destruct date. If it is, insert a new sheet and delete the remaining sheets besides the new one and then save it. Next time it is opened, it's a workbook with one blank sheet in it. Your other option would be to save it with a password once the date has been reached, but do not delete all the sheets. -----Original Message----- I am responsible for distributing a business-sensitive worksheet and wish to enable the spreadsheet to become inoperable after a certain date. A long time ago, I recall that it was possible to install a "time bomb" in the spreadsheet, that was a macro which after a certain date deleted lots of pages in the worksheet and then saved itself onto the existing file name. That way, after a certain date, anyone trying to open the file would see the file render itself useless. I do not know how that can be done in recent versions of Excel (2000, 2003). Any suggestions would be much appreciated. . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I code a "self-destruct" triggered after a certain date?
Here is a write-up I have on this subject. Hope it helps.
AFAIK, nothing can be 100% secure in Excel. Any workbooks, worksheets, VB code, etc can be accessed even if password protected. Nonetheless, you can password protect the VB code (select the relevant project in VB, right click, select Properties and then select Protection. This will act as a deterrent for most people who may be interested in viewing the code. With the code protected you could insert a routine to kick in, say, when the workbook is opened or closed such that if the current date is beyond a date you specify, then most of the worksheets get deleted, etc, etc. If you need more detail about this please post back, but one possibility may be as shown below. Remember that if a user does not elect to enable macros when the workbook is opened then the code will not kick in. This macro adds a blank sheet and deletes all the other sheets. The blank sheet is necessary because an error will be produced if you try to delete the last sheet in a workbook. Private Sub Workbook_Open() Application.ScreenUpdating = False Application.EnableEvents = False Application.DisplayAlerts = False Dim m As Date, ws As Worksheet m = DateSerial(2002, 1, 31) If Date m Then Worksheets.Add.Name = "XXX" For Each ws In Worksheets If Not ws.Name = "XXX" Then ws.Delete Next ws End If ThisWorkbook.Save ThisWorkbook.Save Application.ScreenUpdating = True Application.EnableEvents = True Application.DisplayAlerts = True End Sub Another macro: Private Sub Workbook_Open() If Date < DateValue("7/1/03") Then Exit Sub Sheets("Destroyed").Visible = True Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets If ws.Name < "Destroyed" Then Application.DisplayAlerts = False ws.Delete Application.DisplayAlerts = True End If Next ThisWorkbook.Save ThisWorkbook.Saved = True End Sub Another idea that appears to have more merit is as follows: In the code within the workbook module have a workbook_close event in which you hide all sheets except one sheet. This one sheet may be a useless/dummy one. Then in the workbook_open event use an if statement to check the date. If the If test for date is true then unhide all sheets and hide the dummy sheet. Exit out of the If statement. This way only if the macros are enabled and only if the date is within the desired/target one would you be able to work on the file AFAIK expiry date checks might be useless because they can be breached by changing the computer Time The If statement would look like: If Date #9/15/2004# Then Note that the # marks force a date. HTH Otto "R Lee" wrote in message ... I am responsible for distributing a business-sensitive worksheet and wish to enable the spreadsheet to become inoperable after a certain date. A long time ago, I recall that it was possible to install a "time bomb" in the spreadsheet, that was a macro which after a certain date deleted lots of pages in the worksheet and then saved itself onto the existing file name. That way, after a certain date, anyone trying to open the file would see the file render itself useless. I do not know how that can be done in recent versions of Excel (2000, 2003). Any suggestions would be much appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
creating a "date selector box" or "pull down box" in a cell | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Can you "duplicate" "copy" listboxes and code to multiple cells? | Excel Programming | |||
"what triggered the event" | Excel Programming | |||
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals | Excel Programming |