COPYING

J

Jim/Chris

I do not know how to do it in a macro but here is the code

Private Sub Command10_Click()
This works even if you are in the application

Dim fso As Variant
Dim boverwrite As Boolean

Set fso = CreateObject("Scripting.fileSystemObject")

fso.copyfile "sourcefile", "destinationfile"

End Sub

Jim
 
D

Douglas J. Steele

Just because FSO lets you copy the file even if it's open doesn't mean it's
a good idea to do so. It's entirely possible that your copy will be
inconsistent if other actions are going on concurrently.

I think it's much safer to use the built-in VBA FileCopy statement:

Private Sub Command10_Click()

FileCopy "sourcefile", "destinationfile"

End Sub

(and in your example, it would be better to declare fso as an Object, not as
a Variant. It might also be a good idea to have Set fso = Nothing at the
end.)
 
A

ARMOUDIAN

I will give it a try tomorrow.

Thank you for replying.

Adam Armoudian
(e-mail address removed)
580.819.1188
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top