How to write a module that will copy, move and rename files?

  • Thread starter Thread starter NittanyBlu
  • Start date Start date
N

NittanyBlu

I'm creating a database that uses 100+ different data sources. Making things
worse, the names of the files change every month. What I'd like to do is
create a module that will copy all the files I need, move them to an archived
location and rename them so my database can properly import them. Without
this module, I'll have to copy and rename every file manually.
 
NittanyBlu said:
I'm creating a database that uses 100+ different data sources. Making
things worse, the names of the files change every month. What I'd
like to do is create a module that will copy all the files I need,
move them to an archived location and rename them so my database can
properly import them. Without this module, I'll have to copy and
rename every file manually.

VBA includes commands...

FileCopy (copies files and with a different name if desired)
Kill (deletes files)
Name (changes names or moves files)

In your case FileCopy should do everything you want.
 
The File System Object gives you access to files on your machine. You can use
it to copy, delete, rename, move, etc files as needed. I was going to past a
direct link to Microsoft's online documentation, but I think there doing some
weekend work. At any rate, google FILE SYSTEM OBJECT and you'll fine more
than enough documentation.
 
Be aware, though, that FSO is about an order of magnitude slower than using
the built-in VBA functions (which are about an order of magnitude slower
than using API calls)
 
Back
Top