Foolproof Protection of VBA codes

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • Hiii


    I know there is nothing foolproof & an expert can find the way out.


    But is there any way that which can make it difficult for other to look into excel VBA codes. Earlier I used to think that if I put a very complicated password I am safe & recovery programs won't detect that.


    But recently I found one tool (a excel file) which if you open along with your password protected excel (VBA), it simply removes password option & you can access & view codes directly (It's not guessing & Breaking). So any novice can also see your codes just like that within seconds.


    If I am violating any rule by posting this please forgive me. I just want to know if there is any better security for my excel files (congaing a lot of VBA codes)


    Thanx

  • Re: Foolproof Protection of VBA codes


    No rules violation - it's asking to *break* passwords/protection that gets heat!


    To be honest, if code security is important to you, that's something that should have been addressed before starting development... not after.


    Rather than go to the bother of repeating things that've been said many times, I'll just suggest a link - there's some good reading there.

  • Re: Foolproof Protection of VBA codes


    There are some softwares available e.g. Donex but most are expensive & I'm not sure how good they are. See if you can open this

  • Re: Foolproof Protection of VBA codes


    Quote from royUK;630198

    There are some softwares available e.g. Donex but most are expensive & I'm not sure how good they are. See if you can open this


    I was not able to open that. Could you please tell how to do that?
    The software I found disables password option, but in your file it says "Project Unviewable" so it's better that way.


    Thanx

  • Re: Foolproof Protection of VBA codes


    Quote from cytop;630177

    No rules violation - it's asking to *break* passwords/protection that gets heat!


    To be honest, if code security is important to you, that's something that should have been addressed before starting development... not after.


    Rather than go to the bother of repeating things that've been said many times, I'll just suggest a link - there's some good reading there.


    Thanx, I checked the link, got little better understanding now. I don't know much about VBA, whatever codes I have in my excel files it's due to helpful people like you on this forum, & internet. I just copy paste & do little modification here & there.

  • Re: Foolproof Protection of VBA codes


    I've seen Roy's approach before - or at least I think I have, it uses the in built mechanisms of Excel with regards to viewing projects in a shared workbook. Excel thinks the project is shared - even though the workbook isn't so won't show you the code. It's pretty ingenious, but imo even easier to view than the usual password protection. I haven't tried googling it, but I think it's a little less well known than the password cracking/hex approaches so users are less likely to find how to view the code (although in fact the method is easier than usual password protection).


    Ultimately there is no sure-fire way to protect your code, Excel is inherently insecure. I believe you'd get security by writing the code in .Net, compiling it and using it as an add-in. It is however much more work, so it's always a balance of how usable the code is or easy to write vs how bothered you are about people viewing your code. IME, for a commercial package, users are far more bothered about having support than they are about having a few free copies so are happy to pay for things.


    If you're really bothered, the package that seems most secure to me (though I haven't tried it) is LockXLS since it wraps the workbook in an application. Though to be honest, I'd just stick a password on it/use Roy's method and be happy that >95% of people will use it properly.

  • Re: Foolproof Protection of VBA codes


    yes, me too, it exhibits the same behaviour that I mentioned before - I'll have a look for that method, I can't remember the steps off the top of my head - but it's not the same method so I'm curious.

  • Re: Foolproof Protection of VBA codes


    Here is the method I'd seen before:
    1. Save the Excel workbook (.xls) file into an add-in (File > SaveAs.....)
    2. After you have the saved add-in (.xla), close the Excel workbook (.xls)
    3. Double click on the add-in to open it
    4. Press Alt+F11 to access the add-in's vba project
    5. Lock the vba-project with a password
    6. Double-click on the "ThisWorkbook" code module
    7. Press F4 to open the Properties window
    8. Change the "IsAddin" status to FALSE
    9. Return to Excel by Pressing Alt+Q (or close the vbe window)
    10. Go to Tools > Share Workbook
    11. When the dialogue appears, check the box for: (Allow changes by.....)
    12. Press OK to close the Dialogue
    13. When prompted to save, Press OK
    14. Press Ok to accept that "macros cannot be accessed"
    15. You should feel giddy at this point because you just realized what you have
    been missing right under your nose
    16. Verify that the [SHARED] appears in the application title bar
    17. Now save the workbook again as an Add-in (File > SaveAs...) overwriting the
    previous one
    18. Close this Excel workbook without saving the changes (you don't need it)
    19. Test out your newly saved add-in (open it, access the vbe, try to expand
    the project window, you should get the new message "Project is Unviewable"

  • Re: Foolproof Protection of VBA codes


    I think the sharing method that kyle is referring to only works with add-ins. The example workbook has the Share Option greyed out, so it can't be used.

  • Re: Foolproof Protection of VBA codes


    I like the approach Roy has, but ultimately all these methods are moot since it takes seconds to view the code in any of them without needing any code.


    Roy's at least makes people scratch their head a bit :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!