IsThereAWayOf
New Member
- Joined
- Sep 19, 2002
- Messages
- 5
How can I set an expiration date to a workbook. For instance, I want a workbook's macros and fields to become unavailable after 12/31/03.
Dim ws As Worksheet
Dim remaining As Integer
Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue("00:00:05"), "KillTheForm2"
Dim StartingDate As Date
StartingDate = #12/11/2002# 'wherever you stored the date when this file was first opened
If StartingDate > Now Then StartingDate = Now
Dim Different As Integer
Different = DateDiff("d", StartingDate, Now)
If Different > 30 Then Different = 30
If Different < 30 Then Different = DateDiff("d", StartingDate, Now)
If Different = 0 Then Different = 1
With ProgressBar1
.Scrolling = ccScrollingSmooth 'my personal preference
.Min = 1
.Max = 30
.Value = Different
End With
remaining = 30 - ProgressBar1.Value
If remaining > 0 Then
Trial_popup.Frameprogress.Caption = remaining & " Days remaining."
Set ws = ThisWorkbook.Sheets("Setup")
ws.Range("e23") = 1
Else
If remaining <= 0 Then
Trial_popup.Frameprogress.Caption = "Trial Period Expired."
Set ws = ThisWorkbook.Sheets("Setup")
ws.Range("e23") = 2
End If
End If
End Sub