Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
copy files
Hi.
How to write a code to copy all the ".xls" files in D:\1 to D:\2 ? thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
copy files
Young-Hwan,
This is one way... You can use code from the Microsoft Scripting Runtime Library. It is included in all recent versions of windows. Please try this first on files you don't care about. If it throws an error there is no undo. "----------------------------------------------- 'Requires reference to "Microsoft Scripting Runtime" in the VBA project. 'Assumes "1" and "2" are folders. 'By replacing "CopyFile" with "MoveFile" you can do just that. 'Jim Cone, June 13, 2004 Sub CopyFilesWithScriptingRuntime() Dim strFromPath As String Dim strToPath As String Dim Fso As Scripting.FileSystemObject Set Fso = New Scripting.FileSystemObject 'Wildcards only allowed in the "from" path and only at the end. strFromPath = "D:\1\*.xls" strToPath = "D:\2" 'False prevents overwriting of files Fso.CopyFile strFromPath, strToPath, False 'Technically not required, but I prefer it. Set Fso = Nothing End Sub '----------------------------------------------- Regards, Jim Cone San Francisco, CA "Young-Hwan Choi" wrote in message ... Hi. How to write a code to copy all the ".xls" files in D:\1 to D:\2 ? thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copy files to clipboard | Excel Discussion (Misc queries) | |||
Copy and Paste Between Files | Excel Discussion (Misc queries) | |||
Copy Files | Excel Programming | |||
Copy values between files. | Excel Programming | |||
copy files from one dir to another | Excel Programming |