View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chris Marlow Chris Marlow is offline
external usenet poster
 
Posts: 74
Default Delete file if it starts with a number

Mike,

Set a reference to 'Microsoft Scripting Runtime' & the following should work.

Public Sub DeleteAllNumericStarts()

Dim fso As New FileSystemObject
Dim fsoFile As File

For Each fsoFile In fso.GetFolder("C:\temp")

If Asc(Left(fsoFile.Name, 1)) = 48 And Asc(Left(fsoFile.Name, 1))
<= 57 Then fsoFile.Delete

Next fsoFile

End Sub

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"Michael Smith" wrote:

I would like to delete all files in a folder where the file name starts
with a number. So it would delete 33.xls but not delete Mike.xls

The file in question is C:\Temp

TIA! - Mike



*** Sent via Developersdex http://www.developersdex.com ***