How to - Check if File Exists in Excel VBA
Tom's answer is correct. Just remember that using the KILL statement does
NOT put the file in the "recycle bin". The file is gone forever, never to be
recovered. (I once had an angry client who KILLed a bunch of files,
expecting them to be available for restoration from the recycle bin. That
is NOT what KILL does!)
>This would be one approach:
>If Len(Dir("c:\windows\test.txt")) > 0 Then
> Kill "c:\windows\test.txt"
> MsgBox "Test.txt has been annihilated"
> MsgBox "Test.Txt never existed"
>> Posted At: Monday, September 14, 1998 1:10 PM
>> Posted To: microsoft.public.excel.programming
>> Conversation: How to - Check if File Exists in Excel VBA
>> Subject: How to - Check if File Exists in Excel VBA
>> In Excel VBA, how do you check to see if a file exists and if so,
>> delete it?