It is very handy to delete a file in vba. You can also remove the entire folder if do not required. Here I will recommend you to use VBA Kill statement. The parameter here is kill path & filename. But kill statement cannot delete read only files. The sample code is as follows :
Code:
Dim KillFile As String
KillFile = "c:\temp\temp.doc"
'Check that file exists
If Len(Dir$(KillFile)) > 0 Then
'First remove readonly attribute, if set
SetAttr KillFile, vbNormal
'Then delete the file
Kill KillFile
End If
Bookmarks