Deleting a File

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi

The last part of my macro is a save command:
ActiveWorkbook.SaveAs
Filename:="H:\Personal\SIGINCUSTODY.csv", FileFormat _
:=xlCSV, CreateBackup:=False

I have a problem, however, in so far as a file of this
name already exists and I want to either:
a) overwrite it automatically (without being asked),or
b) delete it at the start of my macro.

The second option is my preferred option.

Can anyone show me how to do it ?

Thanks in advance
 
Hi Steve

Look in the VBA help for the Kill command

Sub test()
If Dir("C:\rrr.xls") <> "" Then
Kill "C:\rrr.xls"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top