Solved FSO.CopyFile (1 Viewer)

Eljefegeneo

Still trying to learn
Local time
Today, 10:29
Joined
Jan 10, 2011
Messages
904
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?
 

Eljefegeneo

Still trying to learn
Local time
Today, 10:29
Joined
Jan 10, 2011
Messages
904
sorry should have included this also:
Code:
Dim FSO As Object
Dim fSource As String, fDest As String
Set FSO = VBA.CreateObject("Scripting.FileSystemObject")
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:29
Joined
Oct 29, 2018
Messages
21,467
Yes, use Dir() to see if the file exist and then Kill it.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:29
Joined
May 7, 2009
Messages
19,230
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.
 

Isaac

Lifelong Learner
Local time
Today, 10:29
Joined
Mar 14, 2017
Messages
8,777
Strange behavior, indeed
 

Eljefegeneo

Still trying to learn
Local time
Today, 10:29
Joined
Jan 10, 2011
Messages
904
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:29
Joined
Oct 29, 2018
Messages
21,467
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

Top Bottom