Protecting your VBA scripts may seem a little extreme, especially with so many IT experts now recognising the value of open source and free access but it does have a couple of very valid reason within the business environment:
- Protection from unauthorised changes
- Protection from getting broken
Protection from unauthorised changes
This is an important consideration within the business environment, for example, if your script allowed users to enter some data, then it calculated bad debt provisions based off the businesses legal guidelines, that criteria are not something you want to allow anyone to change as the results could be catastrophic
Protection from getting broken
If you are writing VBA scripts within an Excel file that are going out to a lot of users that have a limited understanding of Excel then it is prudent to consider whether the script is worth protecting to prevent anyone from breaking it. This is particularly important if all users are accessing the same Excel file or the file lives on an open network as an over-zealous user could accidentally make a change that causes everything to halt across the business or worse.
Remember that with a large user base there are always going to be users that are inquisitive and decide to view your VBA script to see what is going on behind the scenes, personally I encourage that as it helps people to learn and grow their knowledge of Excel but make sure you encourage it under the right circumstances, not every file you produce should allow access to the VBA script.
How to Protect
Protection is simple and takes the form of password protecting your VBA script, this prevents users without the password from even seeing the script that is within the file.
The useful aspect of password protection is that if someone did have a good reason to look through your script, for example, training or development purposes, then you can always share it with them.
To lock your project, set Project Properties, using the following steps:
Start the Microsoft Visual Basic Editor and open your project.
On the Tools menu, click Project Properties, and then click the General tab.
Set the following properties:
Help File Name
Project Help Context ID
Click the Protection tab.
Click to select the Lock Project For Viewing check box.
Type your password in the Password and Confirm Password boxes.
Save and close your project.
NOTE: Protection does not take effect until you save and close your project.
Learn extensive Excel VBA Programming here and automate your Excel Reports, Processes and tasks.
Happy Excelling – www.Excelgoodies.com