Rename File in VBA for Excel

E

Ekim

hello,

I have difficulties at renaming a single file in VBA for Excel.
Assuming I want to rename the file "elbi_umsaetze_20031112160130.csv" to
"elbi_umsaetze.csv":

I've just tried this:

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

fso.CopyFile "c:\Elba\elbi_umsaetze_*.csv", "c:\Elba\elbi_umsaetze.csv",
True

---------------------------------

The problem about it:

It is not possible to use wildcards as source (here "elbi_umsaetze_*.csv")
and rename it to a single name (here "elbi_umsaetze.csv").
On the one hand it seems logical to me that you cannot rename one or more
files into one single name.
But in this special case there is always only one file in this folder (for
example elbi_umsaetze_20031112160130.csv) to rename. I just don't know it's
exact name (because the end of the name is a combination of date as you may
have recognized), so I have to use the wildcard anyway.
----------------------------------

Can someone offer me a solution therefore?


Thx in advance,

ekim
 

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