Hi,
I want to expire a workbook on a specified date if the user opens it. I was trying to use the Workbook_open event but I am running into different errors. This file is in a shared drive and it is password protected. Could those be the reason for the permission denied error? I also got the "runtime error 91: object variable or with block variable not set" with the below code I was testing with.
I want to expire a workbook on a specified date if the user opens it. I was trying to use the Workbook_open event but I am running into different errors. This file is in a shared drive and it is password protected. Could those be the reason for the permission denied error? I also got the "runtime error 91: object variable or with block variable not set" with the below code I was testing with.
Code:
dt = Format(Now + 2, "mmddyy")
On Error GoTo ErrorHandler
Select Case dt
Case Is > "101614"
With ActiveWorkbook
If .Path <> "" Then
.Saved = True
.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
MsgBox "File expired"
End If
End With
Exit Sub
ErrorHandler:
MsgBox "Fail to delete file: " & ActiveWorkbook.FullName
End Select
End Sub