船舶工程技术手册 pdf:自杀代码1

来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 13:21:58
制作带自杀功能的工作簿  视频http://www.excelhome.net/post/448.htm


超过指定日期的自杀代码!!
 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