VBA Code Protection

SamarthSalunkhe

Board Regular
Joined
Jun 14, 2021
Messages
103
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I’m trying to find the best possible way to secure my vba code.
Currently I'm using the protect with password from VBA properties, but I’ve found there are many videos on YouTube showing how to bypass that password (using a hex editor and some other methods).

I'm working in treasury team where i have protect my VBA from unsecured use, can someone please help to protect VBA via another method.

Thank You.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
As you've discovered, VBA passsword protection is weak at best and simple brute nested loops over ascii values can break them (depending on length of password), let alone hex editors, modifying components of the zipped .xlsm file as well as other methods to crack VBA password.

I think it's almost improbable to do at the level you need, from within the Excel/VBE environment, however, curious if any other readers have methods or suggestions to share :)
 
Upvote 0
As you've discovered, VBA passsword protection is weak at best and simple brute nested loops over ascii values can break them (depending on length of password), let alone hex editors, modifying components of the zipped .xlsm file as well as other methods to crack VBA password.

I think it's almost improbable to do at the level you need, from within the Excel/VBE environment, however, curious if any other readers have methods or suggestions to share :)
Thanks Jack for your reply, I'm here just because I have used some macro protected Bank File's, in that file they have secured it on advance level (which is actually unbreakable), that macro also created by someone that means we can also do it.
 
Upvote 0
Hi,​
since Excel 2010 if updated or better with later versions the only good enough protection is the password at workbook level.​
At VBA level the same ways used by malwares & viruses can be applied like for example hidden modules via some add-in you can find on web​
or any trick on blogs …​
 
Upvote 0
you need a third party compiler and hardware locking to really protect your intellectual property unfortunately. one side benefit however is execution speed is inproved
 
Upvote 0
Some of the time, when someone is looking to protect their VBA code, it turns out what they're wanting to protect is in fact the content of the spreadsheet. If that's the case, you could always just encrypt it separately, but that's a huge hassle and not really practical. In terms of protecting the VBA code, depending on just how impenetrable the code needs to be, you could always obfuscate the final code (example). It can make the code very difficult to make sense of, but again, not uncrackable.
 
Upvote 0
Solution
Some of the time, when someone is looking to protect their VBA code, it turns out what they're wanting to protect is in fact the content of the spreadsheet. If that's the case, you could always just encrypt it separately, but that's a huge hassle and not really practical. In terms of protecting the VBA code, depending on just how impenetrable the code needs to be, you could always obfuscate the final code (example). It can make the code very difficult to make sense of, but again, not uncrackable.
Thank you Dan for sharing such useful method.
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top