|
发表于 2014-5-15 11:32
|
显示全部楼层
本楼为最佳答案
- Private Sub Workbook_Open()
- Sheet1.Activate
- If Year(Date) > Sheet4.[b2] Then
- MsgBox "新年度在d盘许可档案备份目录下自动备份上年度档案表,清空后重新开始工作!", , "提示"
- aa = InputBox("请输入继续工作密码!", "密码录入")
- ' DoEvents
- If aa = VBA.Format(VBA.Date, "YYYYMMDD") Then
- MsgBox "密码正确!欢迎在新年度使用系统!"
- Application.DisplayAlerts = False
- Application.EnableEvents = False
- Application.ScreenUpdating = False
- Dim TheBackUpDir As String
- Dim strFile$
- TheBackUpDir = "D:\许可档案备份"
- If Len(Dir(TheBackUpDir, vbDirectory)) = 0 Then
- MkDir TheBackUpDir
- End If
- strFile = TheBackUpDir & "" & Year(Date) - 1 & "工业产品档案备份.xls"
- ThisWorkbook.SaveCopyAs strFile
- With GetObject(strFile)
- MsgBox .Name
- .Windows(1).Visible = True
- For Each ms In .Sheets(1).Shapes
- If ms.Type = 6 Or ms.Type = 8 Then ms.Delete
- Next ms
- For Each vbc In .VBProject.VBComponents
- Select Case vbc.Type
- Case 100
- vbc.CodeModule.DeleteLines 1, vbc.CodeModule.CountOfLines
- Case Else
- .VBProject.VBComponents.Remove vbc
- End Select
- Next vbc
- .Close True
- End With
- Sheet1.Range("A3:T" & Sheet1.Range("A65536").End(3).Row).ClearContents
- Sheet4.[b2] = Year(Date)
- Sheet1.Select
- Else
- MsgBox "密码错误,程序退出!"
- Application.Quit
- ' ActiveWorkbook.Close False
- End If
- End If
- Application.DisplayAlerts = True
- Application.EnableEvents = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|