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

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.
 
R

Rick Brandt

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.
 
D

dch3

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.
 
D

Douglas J. Steele

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top