You would need to record the opening of the workbook - in a hidden
sheet, the registry or a nmed range.
n If statement would check this and if it equals a ertain value close
the workbook. Something like this
Code:
--------------------
Option Explicit
Option Compare Text
Dim ws As Worksheet
Const MaxUses As Long = 5 '<- change uses
Const wsWarningSheet As String = "Splash"
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'hide all sheets except warning sheet
For Each ws In ThisWorkbook.Sheets
If ws.Name = wsWarningSheet Then
ws.Visible = True
Else: ws.Visible = xlVeryHidden
End If
Next
'record opening in remote cell
With Sheets(wsWarningSheet).Cells(Rows.Count, Columns.Count)
.Value = .Value + 1
End With
End Sub
Private Sub workbook_open()
'check tored usage before cotinuing
If Sheets(wsWarningSheet).Cells(Rows.Count, Columns.Count).Value = MaxUses Then
MsgBox "Trial up", vbCritical, "Trial period"
Exit Sub
End If
Sheets(wsWarningSheet).Select
'unhide hidden sheets
For Each ws In ThisWorkbook.Sheets
ws.Visible = True
Next
'hide warning sheet
ActiveSheet.Visible = xlVeryHidden
End Sub
--------------------
--
royUK
Hope that helps, RoyUK
For tips & examples visit my 'web site' (
http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile:
http://www.thecodecage.com/forumz/member.php?userid=15
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=101883