Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
Hi,
I have problem to delete files, because I only want to delete some file the name have / include the words of "test" on file name, and I don't know the path in my local drive (C:). How can I do? Here is my code for specific path, but how can I change the code for delete if the file name have / include the words of "test" under my local drive (C:). Thanks~ On Error Resume Next Kill "C:\Users\*test*.xl*" On Error GoTo 0 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
I also need to delete the file (have / include file name "test") if
the file is open too (active workbook). And don't want to shown the pop up message on the screen. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
It happens that Hello formulated :
I also need to delete the file (have / include file name "test") if the file is open too (active workbook). And don't want to shown the pop up message on the screen. Uh.., you can't delete an open file so that's not going to fly! -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
is it any way change the file to read only, then can delete files?
if ignore the open file this problem, how can I delete the files (have / include file name "test"? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
So, how can I change the code to delete file name have / include
"test"? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
on 2/12/2011, Hello supposed :
So, how can I change the code to delete file name have / include "test"? I expect you'd need to do a search of all drives/folders to locate all files that you're looking for. Sounds like you need to spend some time reading the VB help file. Otherwise, someone who has code for that needs to step up. (Sorry, but I don't have anything readily available) -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
Hello expressed precisely :
is it any way change the file to read only, then can delete files? if ignore the open file this problem, how can I delete the files (have / include file name "test"? No! Windows will not allow you to delete files in use. -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
Hi Gary,
I don't need the code for delete files in use now. Could you teach me how can I change the code to delete files when I need to run this marco on my teammate's (users) computer, not on my computer, so I cannot search all of drives / folders. On Error Resume Next Kill "C:\Users\*test*.xl*" On Error GoTo 0 Thanks |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
Activeworkbook.ChangeFileAccess Mode:=xlReadOnly kill activeworkbook.fullname On 02/11/2011 22:35, Hello wrote: I also need to delete the file (have / include file name "test") if the file is open too (active workbook). And don't want to shown the pop up message on the screen. -- Dave Peterson |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
Hi Dave,
How can I delete file have / include "test" in file name under C drive and don't know the path? I want to delete all files have / include "test" . |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
Maybe you should look up the definition of the terms "angry mob" or "fired"... "New Testament Verses" "Test Results-Five Year Project" "My court testimony" -- Jim Cone Portland, Oregon USA http://www.mediafire.com/PrimitiveSoftware (List Files: specific files/folders with hyperlinks) "Hello" wrote in message ... Hi Gary, I don't need the code for delete files in use now. Could you teach me how can I change the code to delete files when I need to run this marco on my teammate's (users) computer, not on my computer, so I cannot search all of drives / folders. On Error Resume Next Kill "C:\Users\*test*.xl*" On Error GoTo 0 Thanks |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
"GS" wrote in message
... on 2/12/2011, Hello supposed : So, how can I change the code to delete file name have / include "test"? I expect you'd need to do a search of all drives/folders to locate all files that you're looking for. Sounds like you need to spend some time reading the VB help file. Otherwise, someone who has code for that needs to step up. (Sorry, but I don't have anything readily available) Here's a code snippet that finds all the workbook files in the current folder and calls another procedure for each one. As Garry suggests, spend some time digging into the VBA help ... perhaps this will help you along: ' Get list of workbook files in "current" folder filename = ActiveWorkbook.Path & "\*.xl??" filename = Dir(filename) Do 'Debug.Print filename ExtendIndex ActiveWorkbook.Path & "\" & filename filename = Dir() Loop Until filename = "" Dir is a VBA function, there are related functions that allow you to change the current directory, etc. .... there is also a file system object that I have never worked with but might be better suited to your need. -- Clif McIrvin (clare reads his mail with moe, nomail feeds the bit bucket :-) |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
Dave Peterson laid this down on his screen :
Activeworkbook.ChangeFileAccess Mode:=xlReadOnly kill activeworkbook.fullname On 02/11/2011 22:35, Hello wrote: I also need to delete the file (have / include file name "test") if the file is open too (active workbook). And don't want to shown the pop up message on the screen. Thanks, Dave! I didn't think this was possible but I see I was wrong. This adds a whole new dynamic to file management... -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can delete file by Marco
First, I wouldn't do this kind of thing using excel.
I'd use windows search/find to look for: *test*.xl* Then I could look at the results and check to see if each should be deleted. If I didn't have to verify the results, I could just select all the files on the right hand side window (by hitting ctrl-a) and hit the delete key. But if you wanted to search all of drive C: including subfolders, then you could use application.filesearch in xl2003 and before. If you're using xl2007 or higher (works in previous versions, too), you can use code at Ron de Bruin's site to loop through subfolders. He has a couple of ways he http://www.rondebruin.nl/fso.htm and http://www.rondebruin.nl/copy3.htm Again, I wouldn't use excel for this -- even though it's possible. On 02/12/2011 08:51, Hello wrote: Hi Dave, How can I delete file have / include "test" in file name under C drive and don't know the path? I want to delete all files have / include "test" . -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Marco to Delete Worksheets | Excel Discussion (Misc queries) | |||
marco to delete empty columns | Excel Programming | |||
marco to delete empty columns | Excel Programming | |||
marco to delete rows | Excel Discussion (Misc queries) | |||
A Marco Delete Question | Excel Programming |