Permanently deleting files

RichardMGreen

Well-known Member
Joined
Feb 20, 2006
Messages
2,177
Hi all

I've got some VBA that imports csv files into Access tables and it works very well.
As each file is imported, the CSV is deleted (i.e. sent to the recycle bin) using the Kill command because of what the file contains.

Is there any way of permanently deleting the file or emptying the recycle bin at the end of the routine so the files cannot be restored?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The FileSystemObject could be of use.

Set a reference to the Microsoft Scripting Runtime.

Sample:
Code:
Sub DeleteAFile()
    Dim FSO As Scripting.FileSystemObject
 
    FSO.DeleteFile "*.txt", True
End Sub

note: you can use FSO.DeleteFile or FSO.DeleteFolder
...or < filename >.Delete or < directory name >.Delete

The True parameter lets you delete read-only files / directories. Set to False otherwise.

Denis
 
Upvote 0

Forum statistics

Threads
1,224,558
Messages
6,179,512
Members
452,920
Latest member
jaspers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top