Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default 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
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
creating a "date selector box" or "pull down box" in a cell GaryK Excel Worksheet Functions 2 September 30th 09 01:45 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Can you "duplicate" "copy" listboxes and code to multiple cells? HotRod Excel Programming 1 September 1st 04 05:03 PM
"what triggered the event" Rod Jones Excel Programming 1 June 19th 04 10:10 AM
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals BruceJ[_2_] Excel Programming 3 November 20th 03 01:55 AM


All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"