模块:
Public Function Deleteit()
'建立文件夹
If Dir("D:\ProducePlan\") = "" Then
MkDir "D:\ProducePlan"
End If
'删除已存在的文件
If Dir("D:\ProducePlan\" & Date & ".xls") <> "" Then
Kill "D:\ProducePlan\" & Date & ".xls"
End If
End Function
当主窗体关闭时:
Private Sub Form_Close()
Call Deleteit
End Sub