Something Challenging

S

Swift2003

ello

This is gonna sound abit strange but wonderin if there is some sort o
code to make my VBA destroy it's self (or at least criple) after bein
run x amount of times. the story is i've finished my little project
work and have got to pass it on so the cheese's can approve it but
dont exactly trust them not to distribute it and give me nothin 4 m
time/effort. i need the VBA to run say 10 times so the right people ca
see it but then cripple it's self so they have to sort me out 2 make i
continue to work. I've already taken evey possible precautio
passworded etc so they cant mess with the code/sheets.

please help me out, i'll be very happ
 
A

Anne Troy

Well, unfortunately, Excel isn't real secure, but you could try this. Put a
1 in any cell, even on its own hidden sheet. Put, in the workbook open
event, code to add 1 to the value of that cell. Also an IF that if the value
of that cell is 11, to just throw up a message box that says "you let it
expire, you dork", and closes the file.

But what happens if they don't enable macros? You'd better make sure you
throw up a blank worksheet (or one that tells them to enable macros) when
the workbook opens without macros...
<-*-><-*-><-*-><-*-><-*-><-*-><-*-><-*->
Hope this helps!
Anne Troy (better known as Dreamboat)
Author: Dreamboat on Word
Email: Dreamboat*at*Piersontech.com
Web: www.TheOfficeExperts.com
<-*-><-*-><-*-><-*-><-*-><-*-><-*-><-*->
 
S

Swift2003

thanks, sounds good although i not sure of coding but still, as leas
i've got the jist of what to aim
 
S

ste mac

Hi Swift2003, I got this code from this ng, but I can't remember who actually
provided it (appologies), anyway, could be adapted to do what you want...

Option Explicit

Private Sub Workbook_Open()
'Public should be private when doing this for real
Dim myCutOff As Long
myCutOff = DateSerial(2002, 10, 6)

If Date > myCutOff Then

MsgBox "I'm sorry, this workbook should have expired on: " _
& Format(myCutOff, "mm/dd/yyyy") & vbLf & _
"After you dismiss this box, this program will pause for: " _
& CLng(Date) - myCutOff & " seconds!" & vbLf & vbLf & _
"One second for each day past expiration!"

Application.Wait TimeSerial(Hour(Now), Minute(Now), _
Second(Now) + CLng(Date) - myCutOff)

End If

End Sub

Thsi one actually deletes a selected module(s), adjust to suit...

Sub test()

MsgBox "place your code here"

With ThisWorkbook.VBProject.VBComponents
.Remove .Item("Module1")
End With
End Sub

and finally this code closes the wb without saving any changes then
quits excel itself...

Option Explicit
Dim WB As Workbook

Sub RunCloseMe()
'adjust time and or date
Application.OnTime Now + TimeValue("00:00:20"), Procedure:="CloseMe"
End Sub
Sub CloseMe()
Set WB = ActiveWorkbook
Application.DisplayAlerts = False
WB.Save
With Application
.DisplayAlerts = True
.Quit
End With
End Sub

hope these help...

seeya ste
 
Top