Is there a way to copy a file when the file is open?
I have the following, but it will error when the file is open:
[vba]FileCopy "U:\folder\file_name.xls", "U:\folder2\file_name.xls"[/vba]
Is there a way to copy a file when the file is open?
I have the following, but it will error when the file is open:
[vba]FileCopy "U:\folder\file_name.xls", "U:\folder2\file_name.xls"[/vba]
________________________________________
The more questions I ask and the more I learn, I realize that I don't know squat!!!
[vba]
Const FileName1 As String = "U:\folder\file_name.xls"
Const FileName2 As String = "U:\folder2\file_name.xls"
CreateObject("Scripting.FileSystemobject").CopyFile FileName1, FileName2
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Thanks XLD! It seems to have worked.
If I want to copy 2 files or more would I just need to duplicate the script, or would it cause issues with something?
________________________________________
The more questions I ask and the more I learn, I realize that I don't know squat!!!
No, don't duplicate it, it will instantiate a filesystemobject each time.
Rather use this approach
[vba]
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemobject")
fso.CopyFile FileName1, FileName2
fso.CopyFile FileName3, FileName4
'rest of code
Set fso = Nothing
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Works great, thanks!
________________________________________
The more questions I ask and the more I learn, I realize that I don't know squat!!!