Delete a file using the SHELL function


Posted by Pierre on December 20, 2001 3:30 AM

Hello,
I would like to know what is the fastest way to delete permanently a zip file. I guess it is by using the shell function, is it correct?
If yes, can anyone help me on the followind SHELL line command:

sub DELETEFILE()
Dim sZipit as string
Const sDestination = "C:\FileName.zip"
sZipIt = Shell("del " & sDestination, vbMinimizedNoFocus)
end sub

Posted by Paul Akkermans on December 20, 2001 5:27 AM

Hoi,

Use Kill the On Error Resume Next statement prevent a error message when the file doesnot exist.

sub DELETEFILE()
Dim sZipit as string
Const sDestination = "C:\FileName.zip"
On Error Resume Next
Kill sDestination

end sub



Posted by Pierre on December 20, 2001 6:02 AM

Thanks, Merry Christmas and happy new year

Thanks,
The KILL function was exactly what I was looking for.
Merry Christmas and happy new year.

: Hello, : I would like to know what is the fastest way to delete permanently a zip file. I guess it is by using the shell function, is it correct? : If yes, can anyone help me on the followind SHELL line command: : Dim sZipit as string : Const sDestination = "C:\FileName.zip" : sZipIt = Shell("del " & sDestination, vbMinimizedNoFocus) : end sub