Problems using CopyFile on FileSystem object

Hi.

I have this code in VBA:

Dim fso As Object
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
fso.CopyFile(source, destination, true )

Open in new window


Where source and destination are the name of a file to be copyied and a file that already exists but should be replaced.

This worked before on a computer with Windows 7, but now it is installed on a new computer with Windows 8.1 and it doesn't work, but don't get any error too.

What could be happening?
Is this  away to detect an error if it is (for example a lag of permissions) ?

Any help would be appreciated. Thank you.
LVL 15
gplanaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeCommented:
Is this being run from within Access or Visual Basic?

In Access, I don't usually bother with the file scripting object, I usually use:

IF Dir(Destination) <> "" Then Kill Destination
filecopy source, destination
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
danishaniCommented:
Do you have error handling in place?

On Error Goto ErrHandler
'...
ErrHandler:

MsgBox Err.Number & " " & Err.Description

Open in new window

0
Dale FyeCommented:
Sometimes I'll rename the destination file if it already exists, then do the copy operation, and then delete the old (renamed) file if the FileCopy operation succeeds.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jerry_JusticeCommented:
Does it work if the files do not exist?

I would delete the files first and see if it copies the files successfully.  You need to find out if Win 8 is even letting the script run at all.

Also, what folder are you trying to copy files to?
0
gplanaAuthor Commented:
I'ts made in Access, but it worked before.
I had to say that before it was Access 2007 and now it is Access 2013. Could this affect ?
I don't have on error statement. Should I add it?
0
NorieVBA ExpertCommented:
What are the source and destination?

Have you checked that you have permission to read/write to the folder(s) they point to?
0
danishaniCommented:
I'ts made in Access, but it worked before.
 I had to say that before it was Access 2007 and now it is Access 2013. Could this affect ?
 

It might, but I am not able to verify this.

I don't have on error statement. Should I add it?
I think it is always good to add it, however if you got an error and you don't have an error handler in place, it should still pop-up. It's just a better way to handle errors. So I am not sure what's going on.

Do you have any missing references in your Access Database?
Check Tools > References > MISSING ?

Daniel
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
RE:
fso.CopyFile(source, destination, true )

Seems this should be:


fso.Copy (source, destination, true )

I don't think there is CopyFile in the FSO object.

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
I use FSO all the time, considering it's VERY powerful.

m
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.