PDA

View Full Version : Auto Corrupt/Delete an Excel File



Achilles08
01-06-2008, 04:43 AM
Hi,

I supply information to clients in an excel file. The client may use the information several times. To prevent my information from being used beyond a particular date, I would like to write a macro to auto corrupt or lock my excel file. How can I do it using VBA ?

Thanks,
Achilles

Bob Phillips
01-06-2008, 05:08 AM
Don't you think that this might p#*s off your clinets somewhat? Surely, you would be better establishing a good working/paying relationship, or not deal with them.

unmarkedhelicopter
01-06-2008, 07:14 AM
If your clients have 2 brain cells this is impossible to do.
1. they can disable macros
2. they can refer back to original copy (email, cd, dvd etc.)

You would just be making yourself a target for snide comments.

Simon Lloyd
01-06-2008, 09:34 AM
If "Revert" to the original copy you will have lost all your data so unlikely, if you have used the Kill command to delete the file they cannot import the data, granted they can disabel macro's but they would not have the functionality of the workbook so they are unlikely to do this plus not knowing when the expiry date is set for or what the outcome of expiration would be!

Achillies, search the Kb here for setting a trial period for your workbook there are a couple of solutions to what you want to achieve.

Achilles08
01-06-2008, 10:50 AM
Yeah, the trail period thingy is what I wanted. I don't care if clients get p*#sed off !

Thanks,
Achilles

Simon Lloyd
01-06-2008, 11:31 AM
follow this http://vbaexpress.com/kb/getarticle.php?kb_id=475 its a submission by Johnske should match your requirements!

unmarkedhelicopter
01-07-2008, 02:35 AM
So each NEW file gets a NEW log file.
If they open your file for the first time, close it then search their C drive for files created in the last 10 mins ...
It will probably have to be on the C: drive (Though I have created some NT systems in the past without a C: so they would cause you a major problem (I know of 1 major organisation with only a Z: drive and UNC's, no mapped allowed)), you could check where the Excel file is being run from and work out some folder permutation from that, but that would be pretty easy to spot.
You didn't say if your file was an application or merely some data. If data, they will just learn to copy it as it arrives and discard your file, or just never allow macros to run). If an application ... well it would have to save me considerable effort for me to go back after you'd trashed it.
If my organisation had 10 PC's I'd load it on each one when the previous expired on the last and thus get 10 times the use.
Deletetion of data / code (without user consent) contravenes computer misuse legislation in most countries, which is why most 'trial ware' just writes to the registry (or an ini/log file as the example above) and checks validity each time it's run and does not allow access but also does not delete anything (so be VERY carefull if you choose that route).
As I said earlier, anyone with two brain cells, could stop this and if they had three, they could remove your project password and disable 'that troublesome security code' too.
I literally can't think of a scenario where this would be work as a business model, though it could be useful within a company to control certain 'business practice information/tools' and ensure updates are distributed and used in a timely manner.
If you did this to me, and I was even bothered, it would take me less than 3 minutes to fix it and any 'good will' I had, would have evapourated.
If you don't believe me, post me a book and I will find it's heel !!! :)

Simon Lloyd
01-07-2008, 03:23 AM
I literally can't think of a scenario where this would be work as a business modelI'm not one to dwell on semantics but you kind of de-qualified your previous statement with this one
though it could be useful within a company to control certain 'business practice information/tools' and ensure updates are distributed and used in a timely manner., that aside i think the Op is probably best situated to know whether his clients are that way inclined or not, i guess he will have to force them to allow macro's in order to have the functionality of the workbook, for the general and not bloody minded clients or end users the actions that could be taken to circumvent Excels very poor security would not be taken let alone thought about.

Achillies if you also search the Kb for an entry on forcing the user to allow macro's (which i also think is by Johnske) you will find that useful too!

unmarkedhelicopter
01-07-2008, 05:37 AM
Simon, well you are obviously one to dwell on such but you are wrong in that as a business model (achieving reward for ones efforts), it does not work. The second instance regarding 'business practice information/tools' (These are 'business practices' and not a saleable product, unless you can find a buyer from a business competitior) covers where a business thinks that a discount profile for certain customers is 'secret business critical information' or even how a plasterer works out the cost of a job e.g. height * width * var1 + total_edge_length * var2. Foe Example the first thinks that the profile is what makes them profitable (dubious but they must have their reasons) and the second that if another plasterer gets their formula they could just deduct $5 from the result and win every contract. i.e. they are completely different situations. Also the instances where they are used to control updates are usually considered as a bloody nuisance by the users. If you are still in any doubt about this you could read some MBA course material.
I agree that the OP is in a better position to know his clients preferences but circumvention is easily achieved and a simple web search will point out methods and tools for doing so.
I did not say that he should not do this (the trial period bit) but that he should be aware of the possible consequences.
I must be very naive to think that a company employing a coder of Achillies undoubted skill level would even consider that Excel security was anything more than a child-proof door catch.

Simon Lloyd
01-07-2008, 05:59 AM
UMH, i do find that whilst it may be amusing the inane waffle that we sometiimes get drawn in to on an Op's post only detracts from the subject and serves to alienate the Op from posting further, we have to remember that we are here of our own free will to help those with a little less skill than ourselves.......i love to help thats why i gave the suggestions i did, it is not for me to decide whether the request had validity or reprocussions....in fact the only posts i will not give an answer or suggestion to is that of password breaking!

unmarkedhelicopter
01-07-2008, 06:13 AM
touch