PDA

View Full Version : Protecting coding



Domixt
12-13-2006, 09:01 AM
I'm releasing some of workbooks onto some people to test. I have a procedure that deletes the workbook, but I'd like to run this as soon as the VBE is opened. What coding do I use and where should I place it?

Many thanks,
Dom

austenr
12-13-2006, 09:59 AM
Hi, welcome to VBAX!! Put the code in the Workbook Open event. To find that, open the VBE and click on the top left and change to Workbook. Then on the right change to open. The code goes in there.

Domixt
12-13-2006, 10:04 AM
Thanks for the quick reply.

Would this be everytime the workbook opened or everytime the VBE opened? I'd like it to only be when the visual basic editor window was opened. Cheers,

Dom

Cheers

austenr
12-13-2006, 10:09 AM
Oh, that puts a different twist on it. Not sure if it can be done or not. If it can you can bet someone here can help you. I dont know for sure.

austenr
12-13-2006, 10:14 AM
Point of clarification. You want to delete the whole workbook or just the code? I would assume the code.

austenr
12-13-2006, 10:18 AM
See if this KB entry helps you. I could be modified to do what you wish.

http://www.vbaexpress.com/kb/getarticle.php?kb_id=511

Domixt
12-13-2006, 10:23 AM
Either delete all the coding / UF's etc...
or delete the entire workbook.

I have a procedure that deletes the workbook, I just need a place to call it.

Ideally it would be in activation of the VBE, but can't figure out how to get this.

Thanks again

Bob Phillips
12-13-2006, 02:30 PM
Why would it be the activation of the VBIDE? In normal workbook processing, it wouldn't be opened at all. In what circumstances would you be activating it?

Domixt
12-13-2006, 02:39 PM
Well i want them to use the workbook, just not access the coding! So on activation of the vba window it would run a procedure that would shut it down.

Dom

slooftsuj
12-13-2006, 02:43 PM
I have an excel workbook that I send out every month to our customers. To protect the knowledge behind it, I just lock it for viewing in VBE by going to properties of the project in VBE and then to the Protection tab and lock for viewing and put in a password (a very long password). In addition I put a timer in it so that the tool locks out every 45 days so that it can not be accessed.

johnske
12-13-2006, 04:32 PM
You're wasting your time trying to provide fool-proof security in VBA, there's just too many ways to get around it.

However, maybe you'd like to try modifying this (http://xlvba.3.forumer.com/index.php?act=ST&f=6&t=258&st=0#entry355) to suit, it uses the On-Time method to check if the VBE window's open/unlocked and then deletes all VBA code if a hidden password isn't there, but you'd really need to modify it so it's used in an add-in to maybe have some chance of success...

Note that you can only ever provide some extra levels of protection, but don't make the mistake of thinking "protection" is "security" - it is not. Excel VBA is not a secure environment (http://xlvba.3.forumer.com/index.php?showtopic=270&hl=)