how to delete excel file automatically with time period
Here we save the excel workbook with this macro code as .xlsm file format.
This code simply paste in the Developer- Visual Basic and Select ThisWorkbook option in
VBA Project section and simply paste this code.
Private Sub Workbook_Open()
Dim Start, Finish, TotalTime, TotalTimeInMinutes, TimeInMinutes
Start = Timer
Do While Timer < Start + (10 * 60)
DoEvents
Loop
Finish = Timer
TotalTime = Finish - Start
Application.DisplayAlerts = False
Application.Quit
If Date >= #9/5/2010# Then KillMe
End Sub
Function KillMe()
With ThisWorkbook
If Len(Dir(.FullName)) Then
.Saved = True
On Error Resume Next
.ChangeFileAccess Mode:=xlReadOnly
On Error GoTo 0
SetAttr .FullName, vbNormal
Kill .FullName
.Close SaveChanges:=False
End If
End With
End Function
No comments:
Post a Comment