View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Marco Pagliero Marco Pagliero is offline
external usenet poster
 
Posts: 1
Default Macro to move files gets an error if it already exists...

On 5 Mrz., 20:00, JLatham <HelpFrom @ Jlathamsite.com.(removethis)
wrote:
Or you could simply use
KILL NewFilePath
since you've already set that up in your code. Got in too big of a rush to
copy. So

Function TXTFileMove()

OldFilePath = "C:\Import Files\New\" & TXTFileName
NewFilePath = C"\Import Files\Complete\" & TXTFileName
On Error Resume Next
KILL NewFilePath
If ERR<0 Then
ERR.CLEAR
End If
On Error Goto 0
Name OldFilePath As NewFilePath

End Function

KILL doesn't generate an error if the file doesen't exist, KILL
generates an error only if the file is open. So maybe "on error resume
next" and the rest are not necessary after all.

Greetings
Marco P