MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Macro to delete a file


Posted by Peter Brams on August 09, 2001 8:55 AM

Weel what I want is to move a file (after processing it) from one directory to another.

Any help would be appreciated

Thanks

Peter


Posted by Ryan on August 09, 2001 9:04 AM

Sub MoveFile()
Dim SourceFile As String
Dim DestinationFile As String

' Customize Source and Destination Files
' Define Source and Destination
SourceFile = "C:\My Documents\File1.xls"
DestinationFile = "C:\Windows\File1.xls"

' Move File
FileCopy Source:=SourceFile, Destination:=DestinationFile

' Delete Old File
Kill SourceFile

End Sub

HTH, Ryan