PDA

View Full Version : Limiting the no of times a macro can run



r_mundhra
10-08-2007, 11:19 PM
Dear All

I am looking for a code which shall limit the no of times a macro can be run.

Say I am using this undermentioned simple code:-

Sub PasteSpecialValue()
Selection.Value = Selection.Value
End Sub

I want that, say, after having this code run for x (10) times, the code just does nothing....i.e it becomes inoperative/ ineffective when I am trying to run for 11th time. Here "x" can be set to any number.
Thanx

unmarkedhelicopter
10-09-2007, 02:04 AM
ten times ever ? or ten times since loading ?

if it's ten times since loading create a global variable say lnCountLimit as long then every time you run the code increment the value, lnCountLimit = lnCountLimit + 1, if the value reaches 10 exit the code.

r_mundhra
10-10-2007, 05:29 AM
It is 10 times ever..can you please suggest the code

unmarkedhelicopter
10-10-2007, 07:37 AM
In that case you are talking about setting conditions for software to expire i.e. trialware
This can be done but there is always a weak link in the chain and I've never come across one I can't break in about ten minutes.
It is against the rules of this forum to discuss hacking so the discussion on protection is fairly limited also ... but what have you got that is SOOOOO valuable ?