PDA

View Full Version : Solved: help,about use 2 vba at the same time



jinvictor
06-21-2006, 03:24 AM
how can i put the following 2 vba together, so when the workbook expired or over the limited, it will be deleted from the system?
1.

Option Explicit
Sub KillMe()
With ThisWorkbook
.Saved = True
.ChangeFileAccess
Mode:=xlReadOnly
Kill .FullName .Close False
End With
End Sub

2.

Private Sub Workbook_Open()
Dim incRange As Range
Dim StartDate As Date
Set incRange = Range("Increment")
StartDate = "19/06/06" 'Date delivered to customer
Sheets("hidden").Visible = xlVeryHidden
incRange = incRange + 1
Me.Save
If incRange > 10 Or Date - StartDate > 14 Then
Application.DisplayAlerts = False
MsgBox "over the use limit, contact owner"
Me.Close
End If
End Sub


thanx

johnske
06-21-2006, 04:12 AM
What about any data the user may have put into your trial workbook - what's going to happen to that?

jinvictor
06-21-2006, 04:19 AM
all data they put in already save as to other file names, this is only to the original workbook.



What about any data the user may have put into your trial workbook - what's going to happen to that?

johnske
06-21-2006, 04:52 AM
Option Explicit
'
Private Sub Workbook_Open()
Dim incRange As Range
Dim StartDate As Date
Set incRange = Range("Increment")
StartDate = "19/06/06" 'Date delivered to customer
Sheets("hidden").Visible = xlVeryHidden
incRange = incRange + 1
Me.Save
If incRange > 10 Or Date - StartDate > 14 Then
Application.DisplayAlerts = False
MsgBox "over the use limit, contact owner"
KillMe
End If
End Sub
'
Sub KillMe()
With ThisWorkbook
.Saved = True
.ChangeFileAccess Mode:=xlReadOnly
Kill .FullName
.Close False
End With
End Sub

jinvictor
06-21-2006, 05:01 AM
thank you very much, it works perfectly.