Write Code that creates expiration date

  • Thread starter Thread starter queeneileen
  • Start date Start date
Q

queeneileen

I want to write a routine that allows someone to use the template for
a certain time period. After that time period, I want them to stop
using the program without renewing so the information stays current.

The following routine will work, except I want the value to be stored
in a Hidden Workbook or in the Registry. Then I only need to pass one
file (the Hidden Workbook or bat file to update the registry). The
template will be used to create files that will store data, so I don't
want to touch EVERY file if they choose to keep using. The date needs
to be stored externally......


'Private Sub Workbook_Open()
'With Worksheets("Sheet1").Range("A1")
'If .Value = "" Then
' .Value = Now
'Else
'If .Value + 365 <= Now Then
' MsgBox "Expired"
' ThisWorkbook.Close
'End If
'End If
'End With
'End Sub

Can someone assist me with the code?
 
You might find the code on
http://www.cpearson.com/excel/WorkbookTimeBomb.aspx useful. This page has
code that stores an expiration date in either a defined name or in the
registry and when that expiration date has passed, it either closes the
workbook or makes the workbook read-only. Note, though, that it relies on
the user having macros enabled (see
http://www.cpearson.com/excel/EnableMacros.aspx for code to ensure this).
Also, it can been circumvented fairly easily by an experience user. However,
for the majority cases, it will do the job.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
Chip Pearson said:
the user having macros enabled (see
http://www.cpearson.com/excel/EnableMacros.aspx for code to ensure this).
....

Medium macro security means a user could open a workbook with such a feature
with macros DISABLED, then open a new workbook and use macros in the new
workbook to unhide all worksheets in the other workbook.

Someday Microsoft may provide a macro security mechanism that prevents
macros from operating on given workbooks when those workbooks are opened
without their own macros enabled. Or would provide a workbook-level setting
 
Back
Top