First, I do know that there is no sure way to protect an Excel file. They don't provide a good security system. But I feel you can make it very hard for the unexperienced individulas.
I have found a Forced Macro Enable Code and I have tried to add an expire code to it without much excess. It does test , but when I apply it the Marco Enable works fine, but the Expire does not.
If someone could look at the "Expire" part below and tell where I went wrong, I would be greatful. Thank You
Private Sub Workbook_BeforeClose(Cancel As Boolean)
HideSheets
End Sub
Private Sub Workbook_Open()
UnhideSheets
MsgBox "This evaluation program will expire on 8/30/2006"
Dim staticdate As Date
staticdate = #8/1/2006#
If VBA.Now - staticdate < 30 Then
Workbooks.Open Filename:="c:\Evaluiation\Test.xls", Password:="*"
MsgBox "I'm sorry, the evaluation program you are trying to access has expired. You may purchase the full program with all functions from Sunflower-Dillard,Inc. Contact Sunflower-Dillard, Inc. at sunflower_teachers@XXXXX.com. Thank you."
MsgBox "This spreadsheet is no longer active. " & _
"Excel will shut down now", vbExclamation
End If
End Sub
Private Sub HideSheets()
Dim sht As Object
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVisible
For Each sht In ThisWorkbook.Sheets
If sht.Name <> "Macros Disabled" Then sht.Visible = xlSheetVeryHidden
Next sht
Application.ScreenUpdating = True
ThisWorkbook.Save
End Sub
Private Sub UnhideSheets()
Dim sht As Object
Application.ScreenUpdating = False
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
Next sht
ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
End Sub
I have found a Forced Macro Enable Code and I have tried to add an expire code to it without much excess. It does test , but when I apply it the Marco Enable works fine, but the Expire does not.
If someone could look at the "Expire" part below and tell where I went wrong, I would be greatful. Thank You
Private Sub Workbook_BeforeClose(Cancel As Boolean)
HideSheets
End Sub
Private Sub Workbook_Open()
UnhideSheets
MsgBox "This evaluation program will expire on 8/30/2006"
Dim staticdate As Date
staticdate = #8/1/2006#
If VBA.Now - staticdate < 30 Then
Workbooks.Open Filename:="c:\Evaluiation\Test.xls", Password:="*"
MsgBox "I'm sorry, the evaluation program you are trying to access has expired. You may purchase the full program with all functions from Sunflower-Dillard,Inc. Contact Sunflower-Dillard, Inc. at sunflower_teachers@XXXXX.com. Thank you."
MsgBox "This spreadsheet is no longer active. " & _
"Excel will shut down now", vbExclamation
End If
End Sub
Private Sub HideSheets()
Dim sht As Object
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVisible
For Each sht In ThisWorkbook.Sheets
If sht.Name <> "Macros Disabled" Then sht.Visible = xlSheetVeryHidden
Next sht
Application.ScreenUpdating = True
ThisWorkbook.Save
End Sub
Private Sub UnhideSheets()
Dim sht As Object
Application.ScreenUpdating = False
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
Next sht
ThisWorkbook.Sheets("Macros Disabled").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
End Sub