Error 58, file already exists - why?
Thank you for getting back to me, there are no existing files in the
destination folder - confirmed. I tried to follow the code but when using
ofs - it's an area I am not familiar with. The code above just fails
(runtime failure error 58) and says file already exists.
In column A I have the full path c:\input\text.txt
and the output folder is c:\output
The watch statements appear to have the correct values in them.
Sorry for the late reply - even when I have the box "notify me of replies"
marked, I do not get notified. I have checked my junk mail, etc.. and
nothing so I am unsure why. But I will check more frequently. Thanks again
for your help and effort.
"Matthew Herbert" wrote:
Rookie_User,
I left out one of my questions in the original post. Since you are not
testing if the destination already has the source file, do any of source
files already exist in destination?
Best,
Matthew Herbert
"Rookie_User" wrote:
I am trying to move a file from one folder to another - or at least copy and
delete the old file. I get an error 58 file already exists, and don't know
why?
Public Sub MoveFiles(ByVal Source As String, ByVal Destination As String)
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
With oFSO
If .FileExists(Source) Then
.MoveFile Source, Destination
Else
MsgBox Source & " Doesn't Exist", vbExclamation
End If
End With
Set oFSO = Nothing
End Sub
Sub RunThroughList()
Dim I As Long
Dim Destination As String
Dim Lastrow As Long
Lastrow = Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Row
For I = 1 To Lastrow
MoveFiles Range("A" & I).Value, "C:\Output"
Next
End Sub
|