MrExcel Publishing
Your One Stop for Excel Tips & Solutions

thanks folks!... Can you help with this?


Posted by alfredo sanchez on March 09, 2001 9:15 AM

I thank you for helping me on various issues before. Now I want to know if there's a way to date-protect add-ins?. I mean, before distributing the functions in my organisation, I would like to dissable them after certain time. Is that possible?. Thank you.


Posted by Dave Hawley on March 09, 2001 3:09 PM

Hi Alfredo

There are a few ways this can be done, here is one. In your add-in have a sheet who's Visible property is set to xlVeryHidden. Then in the Workbook module for the Add-in put some cde like this:

Private Sub Workbook_AddinInstall()
ThisWorkbook.Sheet2.Range("A1") = Date
End Sub

Private Sub Workbook_Open()
If ThisWorkbook.Sheet2.Range("A1") = Date - 30 Then
MsgBox "Sorry, the 30 day trial is over", vbOKOnly
AddIns("Your Addin Name").Installed = False
End If
End Sub

Dave

OzGrid Business Applications

Posted by alfredo sanchez on March 10, 2001 11:17 AM

Hi Dave:
Thank you for the code but, I don't seem to make it work the way it is intended. Maybe you can tell me the value I have to put in Sheet2("a1"). I tried today's date and compiled, Shifted Windows clock 30 days ahead and tried to load the addin. It Works. I tried one year ahead and still works. Thank you.

Posted by Dave Hawley on March 10, 2001 2:10 PM


Sorry Alfredo, It's been a while since I've done this :O) Looks like I made a couple of mistakes. I shouldn't have used the sheets code name and missed an IF statement.


Private Sub Workbook_AddinInstall()
If ThisWorkbook.Sheets("Sheet2").Range("A1") = "" Then
ThisWorkbook.Sheets("Sheet2").Range("A1") = Date
End If
End Sub

Private Sub Workbook_Open()
If ThisWorkbook.Sheets("Sheet2") <> "" Then
If ThisWorkbook.Sheets("Sheet2") = Date - 30 Then
MsgBox "Sorry, the 30 day trial is over", vbOKOnly
AddIns("Your Addin Name").Installed = False
End If
End If
End Sub

Again this must be placed in the Workbook module of you Add-In. Once you have put the code in save and close your add-in and then install it. Unhide the sheet you use and make sure the date is in cell A1. Now close out of Excel and wind the clock forward > 30 days. Open Excel again and you should get the message.


Dave

OzGrid Business Applications

Posted by alfredo on March 14, 2001 9:55 PM

Thanks Dave, i had to modiff. it a little, but it's working now