Copying Files From One Folder To Another

richlocus
2StarLounger
Posts: 164
Joined: 03 Oct 2015, 00:30

Copying Files From One Folder To Another

Post by richlocus »

Hello:
I know how to copy files from one folder to another folder using Windows Scripting Host. It is quite simple:
___________________________
strPathToCustomerInputTemplate = "C:\Users\" & UserNameWindows() & "\Documents\CustomerUpdates_Before"
strPathToCustomerOutputTemplate = "C:\Users\" & UserNameWindows() & "\Documents\CustomerUpdates_After"

Set FSO = CreateObject("scripting.filesystemobject")
FSO.CopyFolder Source:=strPathToCustomerInputTemplate, Destination:=strPathToCustomerOutputTemplate
__________________________
I could not find a function in Excel VBA that can copy all files in a folder to another folder without using the DIR command and looping. Is there a comparable native VBA command to do the same thing?

Thanks,
Rich Locus

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Copying Files From One Folder To Another

Post by HansV »

No; the VBA command FileCopy does not support wildcards.
Best wishes,
Hans