Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Delete workbook after say 30 days ...

Hi all,

I have a long list of workbooks that are clogging up the
works.

Would it be possible to write a macro that would
automatically delete workbooks after 30 days and make
them non-recoverable from Recycle Bin.

I don't understand any VBA so you would need to write it
out for me. I know how to cut/paste into
Worksheet/book/module etc.

Thanks in advance ...

Susanne
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete workbook after say 30 days ...

Hi,

I wouldn't recommend an automation of such a process and without
programming/adaptation (only with copy and paste), it won't work. But I
can describe, how it can be done.

First you have to make a Reference to the "Microsoft Scripting Runtime"
in VBA Editor, so that you can have a FileSystemObject.

Then following code does the deletion based on date created

Sub doDelete()


Dim fso As New FileSystemObject
Dim fi As File
Dim fo As Folder


Set fo = fso.GetFolder("D:\")

For Each fi In fo.Files
If fi.DateCreated < Date - 30 Then
fi.Delete True
End If

Next

End Sub


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Delete workbook after say 30 days ...

Hi Toltag,

I didn't understand a single word you said ... as I said
I am VBA illiterate.

I can however, copy/paste a script into
Worksheet/Workbook or create a Module.

I don't know if this helps ... I have the date created on
opening the workbook (from a template)in cell AD1.

Would it be possible to write a macro that would delete
the workbook 30 days after the date in cell AD1 which I
could add to my template.

Again, you would need to write the macro and tell me
where it needs to go ... sorry to be a pain!!

Thanks in advance,

Susanne


-----Original Message-----
Hi,

I wouldn't recommend an automation of such a process and

without
programming/adaptation (only with copy and paste), it

won't work. But I
can describe, how it can be done.

First you have to make a Reference to the "Microsoft

Scripting Runtime"
in VBA Editor, so that you can have a FileSystemObject.

Then following code does the deletion based on date

created

Sub doDelete()


Dim fso As New FileSystemObject
Dim fi As File
Dim fo As Folder


Set fo = fso.GetFolder("D:\")

For Each fi In fo.Files
If fi.DateCreated < Date - 30 Then
fi.Delete True
End If

Next

End Sub


---
Message posted from http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete workbook after say 30 days ...

Hi Susanne,

What is the version of Excel you're using

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Delete workbook after say 30 days ...

Hi Susanne
I would recommend not to use MS Excel for this task but a stand-alone
tool (a scheduler) dedicated for this purpose. Reason: MS Excel has to
run (AFAIK) to perform these tasks

E.g. some links to shareware products which may help you (no
recommendation, I've never tested these tools, just a shot search at
www.zdnet.com)
http://downloads-zdnet.com.com/3000-2084-10251848.html
http://downloads-zdnet.com.com/3000-...ml?tag=lst-0-8
http://downloads-zdnet.com.com/3000-...l?tag=lst-0-11
(there are many, many more, just search for 'Scheduler')


Additional note: Are you sure you automatically want to delete files
(without any user interaction). I wouldn't do that
Frank

Susanne wrote:
Hi Toltag,

I didn't understand a single word you said ... as I said
I am VBA illiterate.

I can however, copy/paste a script into
Worksheet/Workbook or create a Module.

I don't know if this helps ... I have the date created on
opening the workbook (from a template)in cell AD1.

Would it be possible to write a macro that would delete
the workbook 30 days after the date in cell AD1 which I
could add to my template.

Again, you would need to write the macro and tell me
where it needs to go ... sorry to be a pain!!

Thanks in advance,

Susanne


-----Original Message-----
Hi,

I wouldn't recommend an automation of such a process and without
programming/adaptation (only with copy and paste), it won't work.
But I can describe, how it can be done.

First you have to make a Reference to the "Microsoft Scripting
Runtime" in VBA Editor, so that you can have a FileSystemObject.

Then following code does the deletion based on date created

Sub doDelete()


Dim fso As New FileSystemObject
Dim fi As File
Dim fo As Folder


Set fo = fso.GetFolder("D:\")

For Each fi In fo.Files
If fi.DateCreated < Date - 30 Then
fi.Delete True
End If

Next

End Sub


---
Message posted from http://www.ExcelForum.com/

.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete workbook after say 30 days ...

Susanne,

The most important thing he said was don't do this, it is not a good idea.
Sooner or later you will delete a file you didn't want deleted, and then
there is no way back unless you have a very good backup strategy.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Susanne" wrote in message
...
Hi Toltag,

I didn't understand a single word you said ... as I said
I am VBA illiterate.

I can however, copy/paste a script into
Worksheet/Workbook or create a Module.

I don't know if this helps ... I have the date created on
opening the workbook (from a template)in cell AD1.

Would it be possible to write a macro that would delete
the workbook 30 days after the date in cell AD1 which I
could add to my template.

Again, you would need to write the macro and tell me
where it needs to go ... sorry to be a pain!!

Thanks in advance,

Susanne


-----Original Message-----
Hi,

I wouldn't recommend an automation of such a process and

without
programming/adaptation (only with copy and paste), it

won't work. But I
can describe, how it can be done.

First you have to make a Reference to the "Microsoft

Scripting Runtime"
in VBA Editor, so that you can have a FileSystemObject.

Then following code does the deletion based on date

created

Sub doDelete()


Dim fso As New FileSystemObject
Dim fi As File
Dim fo As Folder


Set fo = fso.GetFolder("D:\")

For Each fi In fo.Files
If fi.DateCreated < Date - 30 Then
fi.Delete True
End If

Next

End Sub


---
Message posted from http://www.ExcelForum.com/

.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete workbook after say 30 days ...

You could even use a VBScript file, and use the NT or XP built in scheduler
(does 98 have a similar tool)?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Frank Kabel" wrote in message
...
Hi Susanne
I would recommend not to use MS Excel for this task but a stand-alone
tool (a scheduler) dedicated for this purpose. Reason: MS Excel has to
run (AFAIK) to perform these tasks

E.g. some links to shareware products which may help you (no
recommendation, I've never tested these tools, just a shot search at
www.zdnet.com)
http://downloads-zdnet.com.com/3000-2084-10251848.html
http://downloads-zdnet.com.com/3000-...ml?tag=lst-0-8
http://downloads-zdnet.com.com/3000-...l?tag=lst-0-11
(there are many, many more, just search for 'Scheduler')


Additional note: Are you sure you automatically want to delete files
(without any user interaction). I wouldn't do that
Frank



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
Delete entire row if older then 365 days Pas Excel Discussion (Misc queries) 2 April 4th 10 10:13 PM
Need to pull <=14 Days, <=30 Days, 30 Days from a date column Ken Excel Discussion (Misc queries) 3 October 23rd 09 12:53 AM
Delete duplicates on 2nd workbook Dude Excel Discussion (Misc queries) 4 July 21st 09 11:34 PM
How to Delete a Range in Closed Workbook (to Replace Delete Query) [email protected] Excel Discussion (Misc queries) 1 March 8th 06 10:10 AM
how do you delete a workbook Bob Excel Discussion (Misc queries) 2 October 3rd 05 12:18 AM


All times are GMT +1. The time now is 11:49 PM.

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"