Solved FSO.CopyFile

Eljefegeneo

Still trying to learn
Local time
Yesterday, 19:53
Joined
Jan 10, 2011
Messages
902
I am using the following to copy a backend from one folder to another. My code is:
Code:
Call FSO.CopyFile(fSource, fDest, True)
I copied the backend but is asks if I want to replace the existing file. A search of the forum is that possibly I don't have the correct reference ticked off. But I am using late binding. Access 2010

So, either what am I doing wrong or should I just insert a Kill command to delete the old file before I copy it?
 
sorry should have included this also:
Code:
Dim FSO As Object
Dim fSource As String, fDest As String
Set FSO = VBA.CreateObject("Scripting.FileSystemObject")
 
Yes, use Dir() to see if the file exist and then Kill it.
 
strange behavior, since you already put True (force copy) as the third parameter.
if it exists and not in used, it will be overwritten.
if in used, there won't be any error msg, but it will not get overwritten.
 
Strange behavior, indeed
 
I "fixed" it by deleting the old file first and then adding it. The really strange thing is that I use the same code in a different Private sub for another backup of a file and it works perfectly. Fixed is fixed.
 
I "fixed" it by deleting the old file first and then adding it. The really strange thing is that I use the same code in a different Private sub for another backup of a file and it works perfectly. Fixed is fixed.
Hi. Congratulations! Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom