PDA

View Full Version : [SOLVED:] Protection for Excel Sheet



dillon65
03-10-2005, 07:01 PM
Hell everyone:

I have written a script for an invoice, which I need to send to a prospective client.

I am very new to programming, I have used the search help files, however, there are so many proctection for objects, Protection for property.

All I want to do is protect the actual VBA, so that the end user cannot change the script.

"Don't forget to cover 'Cut' as well as 'Copy' and to protect your VBA with a password."

How do I do the above:help

Thanks in advance

Dillon

MWE
03-10-2005, 07:25 PM
VBA code is in one of the VBAProject modules for the xls file. Open the VB editor and right click on the VBAProject. Navigate to VBAProject Properties and then to the Protection Tab. Click the Lock project for viewing box and enter a relevant password (twice). Make sure you write down the password Click OK. The VBAProject remains viewable until you save and close the file. When you reopen the file and attempt to view the VBA code, you will be asked for the password. .

This method is pretty secure. There are ways to crack it but I suspect that this is adequate for your purposes -- after all, you are probably just trying to keep honest people honest.

You may also want to consider adding code to the Workbook_Open procedure to quit the application if certain criteria are not met. For example, you may wish to supply the VBA script(s) to the client for a month of evaluation. You could add a date check in the Workbook_Open proc to ensure that the client only gets 30 days of free evaluation. A really smart client can get around that by resetting the system clock. You can circumvent that by writing "check data" to a hidden and protected sheet so you will know if the client fiddles with the system clock.

dillon65
03-10-2005, 08:38 PM
Hello MWE:

I looked through the bible for 97, and I found the procedure, however, I use Excel 2002.

I have tried, although, when I close, and reopen, I do not get a request for a password; I will follow your instructions.

thank you very much for your support, and guidance.
___________________________________________________
UPDATE: MWE, I have received the password request, as soon as I went back into the VBA Editior.

Again, thank you so much!:clap:

dillon

Paleo
03-11-2005, 08:16 AM
Hi dillon,

dont forget to set it solved if its done.

Simply hit Thread Tool -> Mark Solved.

MWE
03-12-2005, 11:05 AM
Hello MWE:

I looked through the bible for 97, and I found the procedure, however, I use Excel 2002.

I have tried, although, when I close, and reopen, I do not get a request for a password; I will follow your instructions.

thank you very much for your support, and guidance.
___________________________________________________
UPDATE: MWE, I have received the password request, as soon as I went back into the VBA Editior.

Again, thank you so much!:clap:

dillon
Dillon: I should have mentioned that the request for password would occur when you/user attempted to open the protected project in the VBE.

Glad it worked out for you.

MWE

Anne Troy
03-12-2005, 11:17 AM
Password setting in the VBE, as far as I can tell, doesn't really *take* until you close and reopen the file. In other words, during development, you can go in and out of there (sort of like you can a website that you're logged into, but you need to log in again after closing your browser).

dillon65
03-12-2005, 02:15 PM
Hello MWE, Dreamboat, Paleo:

Thank you for your support, I will glady remember to close out the thread.

Again, thank you!

Denise

MWE
03-13-2005, 08:29 AM
Password setting in the VBE, as far as I can tell, doesn't really *take* until you close and reopen the file. In other words, during development, you can go in and out of there (sort of like you can a website that you're logged into, but you need to log in again after closing your browser).
Quite true; and that is why I emphasized writing down the password. It is all too easy to password protect the VBAProject, continue to work for a while and then close the file without consciously thinking about the password. Several days later you resume work on that file and unless you are consistent in password choices or have an unusually good memory, you may spend some non-productive time trying to remember what the password is.

Paleo
03-13-2005, 09:10 AM
Hi MWE,

thats why password crackers are being built everyday, :yes , that really happens a lot and I endorse MWE recommendation.:thumb