As I can save a new file with today's date is there a way to delete or move the old file already in the folder? The file name will be in the same format but the date would be different though in the same format, e.g. 25-07-11. Is there anyway the macro could find this old file and delete it or move it?
I see backups of all reports on our network but generally only keep the latest file on our intranet, so I would need to delete the old file on our intranet and move the old file on our network.
Relating post is here.
Last edited by koltregaskes; 08-17-2011 at 11:34 AM.
Use the Kill command, read the vba help files
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Thank you. How do wildcards work in the Kill statement?
I'd like to delete all files starting with "Combined Town Report" and end with ".xlsx". The bit in the middle is normally the date which differs each day. How would I do this? Every variation I can think of doesn't appear to work.
An additional question to above. I've tried deleting all .XLS files in a folder on our intranet with the following code but I get the error sayign file not found. What am I doing wrong?:
Kill "http://Intranet/cornerstone/Cornerstone Reports/Town Reports/*.xls"
And yes there are .xls files in the folder. :-)
OK, it seems I cannot save or delete anything on that intranet (http) addresses in an Excel macro. Is this correct?
Basically this code works:
But this doesn't:FileCopy "foldername\Combined Town Report 00-00-11.xlsx", "foldername\_OLD\" & "Combined Town Report " & Format(Now, "dd-mm-yy") & ".xlsx"
FileCopy "foldername\Combined Town Report 00-00-11.xlsx", "http://Intranet\cornerstone\Cornerstone%20Reports\Town%20Reports\" & "Combined Town Report " & Format(Now, "dd-mm-yy") & ".xlsx"
Any thoughts on why the Kill command will not work with intranet/internet links? FlieCopy also doesn't appear to work.
The error is bad file but the code is exactly the same apart from being online.
Anyone know why FileCopy and Kill commands don't appear to work on intranet/Internet addresses?
I suspect it's to prevent malicious deleteing
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Right, shame that as it means the marcro will need some manual work still. Ta for the reply.
I've found a solution to this, at least for me. I can change the http addresses to \\intranet\ addresses.
Kill and FileCopy commands seem to work with this type of address. Pretty simple in the end.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks