View Full Version : Solved: CopyFile If
gibbo1715
12-18-2005, 04:19 AM
How can i copy every file in a folder to a new location that starts with 12345 please
Cheers
Gibbo
johnske
12-18-2005, 05:06 AM
Sub CopyEm()
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'set your paths below
FSO.CopyFolder "C:\Windows\Desktop\New Folder", "C:\Windows\Desktop\12345"
Set FSO = Nothing
End Sub
Norie
12-18-2005, 07:49 AM
Gibbo
Do you mean every file that starts with 12345?
gibbo1715
12-18-2005, 10:05 AM
sorry norie, i did mean every spreadsheet that starts with 12345 in the same folder (e.g. C:\Test)
So 12345A.xls
12345B.xls and so on
Cheers gibbo
Bob Phillips
12-18-2005, 10:35 AM
Sub CopyEm()
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FileSystemObject")
'set your paths below
oFSO.CopyFile "C:\MyTest\12345*.xls", "C:\NewDir\"
Set oFSO = Nothing
End Sub
mdmackillop
12-18-2005, 10:36 AM
Hi Gibbo,
A minor adjustment to johnske's code to do this
Sub CopyEm()
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
'set your paths below
FSO.CopyFile "C:\Location\12345*.xls", "C:\NewLocation\"
Set FSO = Nothing
End Sub
gibbo1715
12-18-2005, 11:29 AM
I ve been racking my brains for hours and its that simple :banghead:
thank you for putting me right
Gibbo
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.