Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I make my code inaccessible to viewers of the workbook in Excel97?

Status
Not open for further replies.

MrsTFB

MIS
Oct 3, 2000
307
0
0
US
I have an Excel97 workbook that contains passwords in the code. Users will have to be able to open the workbook, but the passwords in the code shouldn't be viewed by anyone else. Can I encrypt the passwords in the code or make the code only unaccessible? Is this possible?

Thanks for any ideas you might have.


Thanks in advance

Bsimmons [sig][/sig]
 
It is simple to protect your code in Excel. Go to the VBA editor view (Alt + F11) click on the tools drop down menu and choose VBA Project Properties. In the next dialog there is a Protection tab which lets you enter a password and lock the project for viewing. Ticking this box and setting a password will stop anyone seeing the project after it has been saved, closed and re-opened.
Beware, I am not aware of any way of hacking the password so once it is set dont forget it !!! [sig][/sig]
 
If the passwords are hardcoded in the VBA module, follow FatherJack's procedures. Although they can not get into the protected modules, the passwords can still be found with some determination. If you right-click, drag and drop the Excel file into NotePad, you will see the encrypted file. Unfortunately, if the passwords are coded as strings, they will not be encrypted. Again, this will take someone with severe determination to find.

I would say that this will not be a problem 99.99% of the time. If it is still a concern, you still have some options. For example, assume the password is "ABC". Instead of comparing the string to a hardcoded list of passwords, you can check character positions.

if instr(1,sPasswordEnteredByUser,chr(65)) = 1 and _
instr(1,sPasswordEnteredByUser,chr(66)) = 2 and _
instr(1,sPasswordEnteredByUser,chr(67)) = 3 then
'Correct password
else
'no dice
end if

This will be harder, if not impossible to find. Unfortunately, this is probably not a great way to accomplish the task. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top