Contingency Code

Macgyver

New Member
Joined
Jul 14, 2004
Messages
40
I’m fairly new to VBA. I’ve created a few basic programs to make my employer’s business more efficient. It occurred to me that I could make my job obsolete in the process of making everyone’s life easier. So, I’m wondering if there is way to make my code only viable if I am there to delay a potential self-destruct code. Essentially, I am curious if there is a way I can create a code that will erase all of the code on a particular date.

Therefore, while I am still employed I can delay the self destruct code by changing the date in the code periodically. And if I am let go because of the convenience that I have created with my program eliminates the need for me, there will be no one to change the date periodically and the program will self destruct, thus creating a need for me once again.

Just curious..

Thanxs,

Macgyver
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
OK, a few things to consider:

(1)
Your employer might just be like many other foolish employers who release a creative, good employee after said employee implements a time-saving automated program. If that's the case, they are short-sighted and you are better off with a more forward-thinking employer.

(2)
Your employer might just be like many other smart employers who retain people like you to use your skills in other areas now that the automation you implemented has put them ahead of their competition and they don't have to pay someone to manually do what automation can do. Give them a chance to show their stripes before indicting them.

(3)
Eliminating the code you created is an understandable emotion but I still would not do it. I know I know I know how that feels; I spent 20 years automating the processes of my former employers (large real estate and hotel development companies whose names you'd recognize), without commensurate consideration. You get a short term gain of some satisfaction from that, but in the long term, you get further ahead by letting them keep the program and remembering you as the person who created it, not the person who destroyed it. I now own an incorporated Excel development company here in silicon valley after "giving away" these programs, and many projects and subsequent income came from referrals by those former employers. Resist the temptation to get even; it will put you further behind in the long run.

(4)
In 2 years you will look back on that code you wrote as prehistoric compared to the programming skills you will develop, and you'll chuckle and think that they can keep that code, look at what you can do now. It'll be sort of like knowing they are stuck listening to music on yesterday's 8-track tapes instead of today's digital CD's. That should be satisfaction enough for you, and you did nothing wrong to make that be the case.

(5)
In the interest of representing both sides, and by way of general education to answer your question, you can delete a file or just the code in a file.

Place this in a standard module. Modify for suicide date, and make sure you have a backup copy in case you code the date wrong or change your mind later.

Private Sub Auto_Open()
If Date < #12/31/2004# Then Exit Sub
With ThisWorkbook
.Saved = True
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
End Sub


This keeps the file alive but deletes all the code and modules (thanks Chip Pearson):

Private Sub Auto_Open()
If Date < #12/31/2004# Then Exit Sub
Dim VBComp, VBComps
Set VBComps = ActiveWorkbook.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp
ActiveWorkbook.Save
End Sub


(6)
Think about the long term consequences of short term behavior. Restraint from retribution almost always works in your favor, makes you more respected in the programming community, and makes you more money too...nothing wrong with that.
 
Upvote 0
Thanks Tom. Sorry took so long to get back. I appreciate the life advice. I'm not as vendictive as I sound. I was just studying for my accounting finals and decided to take a break and thought "what if?".

But, thank you again for the code and the advice. K, gotta get back to studying.

Macgyver
 
Upvote 0
Macgyyer

Have you looked at the contract you signed when you first started?

I don't know about in the States but here in the UK there are clauses saying anything you've done for them belongs to them.

About 3 years ago I worked for a small company for which I created various bits of code and also set up a very good (in my opinion) UI's.

They passed (sold) this on to their parent company and didn't give me a penny.

I was slightly miffed about this, made my thoughts clear.

They then said that any other code I wrote would be rewarded commensurately.

It wasn't so, I left.

I know other people that work in IT(?) that have felt the same as you and I, but I really don't see the point of being nasty to people that you worked with.
 
Upvote 0
Norie,

There are other uses for this. Such as a primitive form of "trial software." For instance, if you were to create a program to sell to someone, you could insert this code to prevent them copying the program and then declining to purchase it.

---Sure it wouldn't be hard for them to delete the suicide code before it initiates. However, if they were that savvy, then they wouldn't be purchasing a custom program in the first place.

Macgyver
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,343
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top