Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Delete File(s) over a certain age

Hi,

This is obviously a variation on a theme and I realise that the deleted
file(s) will not move to the recycle bin.

On the first business day of a new month ie March, I would like to delete
all the files in a specific folder which are more than a month old, ie from
Jan or before.

I already have a procedure which runs only on the first business day of each
month, so the additional code can be incoprorated into this.

Thanks for your help.

Regards
Richard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete File(s) over a certain age

This is obviously a variation on a theme and I realise that the deleted
file(s) will not move to the recycle bin.


Okay, as long as you realize that the files will not be recoverable...

On the first business day of a new month ie March, I would like to delete
all the files in a specific folder which are more than a month old, ie
from
Jan or before.

I already have a procedure which runs only on the first business day of
each
month, so the additional code can be incoprorated into this.


TEST THE FOLLOWING AGAINST COPIES OF THE ACTUAL FILES FIRST to make sure it
works correctly!!!

' Put these with the rest of your Dim statements
Dim Path As String
Dim FileName As String
' ....
' ....
' Note the trailing backslash... always include it.
Path = "C:\TEMP\Test\"
FileName = Dir$(Path & "*.*")
Do While Len(FileName) 0
If DateDiff("m", FileDateTime(Path & FileName), #3/1/2008#) 1 Then
Kill Path & FileName
End If
FileName = Dir$
Loop

Rick

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 04:38 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:20 PM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"