View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Clif McIrvin[_3_] Clif McIrvin[_3_] is offline
external usenet poster
 
Posts: 203
Default 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 :-)