Option Explicit
Sub KillThisWorkbook() With ThisWorkbook .Saved = True .ChangeFileAccess xlReadOnly Kill .FullName .Close End With End Sub Private Sub Workbook_Open() If Date > #11/18/2010# Then Call KillThisWorkbook End If End Sub 要是清除件内容的话,先用录制宏,获得清除内容的代码,再加入一个一个时间判断语句:
if date>#2010-08-01# then "清除内容的代码" 最后将修改的代码 放在 thisworkbook下 : Private Sub Workbook_Activate() 代码 End Sub 打开三次后自我删除
Option Explicit Sub readopentimes() Dim opentimes As Integer With Me opentimes = .CustomDocumentProperties("opentimes").Value + 1 If opentimes > 3 Then Call killthisworkbook Else .CustomDocumentProperties("opentimes").Value = opentimes .Save End If End With End Sub Sub killthisworkbook() With ThisWorkbook .Saved = True .ChangeFileAccess xlReadOnly Kill .FullName .Close End With End Sub killthiswork 这个已测试不错
Private Sub Workbook_Open()
If Now() >= #9/15/2006# Then ActiveWorkbook.ChangeFileAccess xlReadOnly Kill ActiveWorkbook.FullName Application.Quit End If End Sub Private Sub Workbook_Open() '工作簿打开就执行
Application.DisplayAlerts = False '关闭提示 Dim datee As Date定义datee '为日期 datee = #9/19/2006#为datee '赋值 If Date > datee Then '如果当前日期大于设定的日期 ThisWorkbook.Sheets("Sheet3").Delete '删除表sheets3 ThisWorkbook.Save '保存工作簿 Application.Quit '推出工作簿 End If End Sub 再给一个过期则删除工作簿(回收站都找不到) Private Sub Workbook_Open() Private Sub Workbook_Open() |
|