Jun 12 2011

Date Expire and Password Protect Your Excel Project

When building your Excel projects, you may want to demo a trial version of the work you have completed without giving full access to the working program. There are a couple things you can do to the project to make it difficult to access the vba code you have created. In addition to that, we’ll look at how to add vba code to disable the project from opening.

Adding Expiration Code to the Auto_Open Macro
The goal of the code below is to prevent the workbook from opening if it has exceeded the specified date that you set.  When the project opens, it will check today’s date against the expiration date and immediately close the program (Code below).

[ad#in-post-ad]

Sub Auto_Open()
ExpirationCode
End Sub

Sub ExpirationCode()
Dim ExpirationDate As Date

ExpirationDate = DateSerial(2011, 6, 10)

If Now() >= ExpirationDate Then
MsgBox “Trial Period ended on ” & CStr(ExpirationDate) & “.”
ThisWorkbook.Close savechanges:=False
End If
End Sub

Further Protection of Your Excel Project
If the end user is savvy enough to open the project without running the auto_open macro, you have two more things you can do to help protect your work.

  1. Add the same code above (ExpirationCode) to the other subroutines in your project, so that it checks the expiration dates first.
  2. Add a password to the vba project, so that the code can’t be easily viewed or edited unless you know that password.  To add a password to your vba project, right click on the module and select “VBAProject Properties…”.  Select the “Protection” tab, click “Lock project for viewing” and then add your password to password protect to vba module.  Remember to write you password down so you can later access your project.  To disable the project, go back into the project and remove the password in the same manner.

VBAProject Properties

 

Again, none of these methods is fool-proof against someone that really wants access to the files you are protecting.  They are, however, a good deterrent to protecting your work and is a good starting place to let people know that the software is not yet available for distribution. If you need to open the workbook without running the expiration date code, hold down the shift key while opening the workbook.

More Excel Tips

Did you find this post helpful? Try signing up for our free daily tips.

Enter your email address: 

          

3 Comments on this post

Trackbacks

  1. How to Make a Worksheet Very Hidden wrote:

    [...] making the spreadsheet very hidden, you can password protect to prevent it from being [...]

    October 9th, 2011 at 1:16 pm
  1. gkapackagingmachines said:

    You can’t. a CSV is just a text file which can’t be password protected in excel. The best you could do is zip it in winzip with a password.

    July 18th, 2011 at 1:59 am
  2. playschool gurgaon said:

    I have had to password-protect each individual sheet for privacy reasons. This means that when I open the Master sheet, the only way the data will update now is if I type in 20 separate passwords, one after another.

    July 19th, 2011 at 5:49 am

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog

Sign Up for Excel Hints

Free updates with Excel Hints, Tips & Tricks

Categories

Archives