Copy all or selected Files by type from Folder with Subfolders

User avatar
Stefan_Sand
4StarLounger
Posts: 412
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Copy all or selected Files by type from Folder with Subfolders

Post by Stefan_Sand »

Helllo,

I have a nice macro, where i can choose inside the code, which files (sFileSpec) in a source folder - sPathSource (with all its subfolders, if there are a lot of files in them) have to be copied to a chosen destination folder (sPathDest).

Is there a possibility to choose sPathSource from cell C3 in wsh Parameter, and to choose sPathDest from cell C4 in wsh Parameter, and to
choose file types - sFileSpec - from cell C6 in wsh Parameter by code to avoid to set it all time i have to do this in the code?

Please see the working source. Can someone help me please?

Stef
You do not have the required permissions to view the files attached to this post.

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

Re: Copy all or selected Files by type from Folder with Subfolders

Post by HansV »

See the attached version. I'll leave it up to you to add error checking.

Copy Files Test.xlsm
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 412
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Copy all or selected Files by type from Folder with Subfolders

Post by Stefan_Sand »

Hi Hans, thank you very much as always.

For error checking You meant: - sPathDest = Range("C34").Value & "\"..... ;) ??
Or did you mean with 34 the result of the game from the Elftal against my team tonight? :thumbup:

One question i do really have right now: for filetype in cell C6 what shall i type into it, if i want to copy only pdfs, or docs, or xlsx..? I tried a lot of possibilities, but even if i left it free, nothing happened. I might be missing something, i guess.

Stef

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

Re: Copy all or selected Files by type from Folder with Subfolders

Post by HansV »

C34 should have been C4, sorry - a typo.

I meant that you may want to check that C3 and C4 have been filled.
In C6, enter *.pdf or *.xlsx or *.*
Best wishes,
Hans

User avatar
Stefan_Sand
4StarLounger
Posts: 412
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: Copy all or selected Files by type from Folder with Subfolders

Post by Stefan_Sand »

perfect ! :clapping: :fanfare: