View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
stefan onken stefan onken is offline
external usenet poster
 
Posts: 33
Default copy files by name patterns with wildcard

hi Stefi,
you could use FSO:

Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile "D:\test\filename*.ext", "D:\test\test\"

or

strPath = "D:\test\"
strNewPath = "D:\test\test\"
file = Dir$(strPath & "filename*.ext")
Do While file < ""
FileCopy strPath & file, strNewPath & file
file = Dir$()
Loop

bye
stefan

On 30 Mai, 08:43, Stefi wrote:
Hi All,

Can I copy files via VBA by name patterns with wildcard characters like in
DOS:
copy filename*.ext ...
I know how to find file names matching the pattern and copy them
individually (in a loop), my question is that can it be done with a single
statement?

Thanks,
Stefi