Copy file and rename it using VB


I'd like to copy an existing (*'xls) file from a folder [C:\nbutane\rsview\report\] into the same folder but the new file will be rename.

FileCopy "C:\nbutane\rsview\report\FC Daily Report.xls", "C:\nbutane\rsview\report\FC Daily Report\" & Format(Date - 1, "ddmmmmyyyy") & ".xls"
End Sub

Source (original filename) : FC Daily Report.xls
Target (new filename) : FC Daily Report.xls 07112004.xls

Anyone can verify if the VB code above is correct? Thx.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


FileCopy "C:\nbutane\rsview\report\FC Daily Report.xls", "C:\nbutane\rsview\report\FC Daily Report\" & Format(Date - 1, "ddmmmmyyyy") & ".xls"
End Sub


Do not add the "\" after "FC Daily report". Also mmmm would give u the long month as "November" use mm

it should be

FileCopy "C:\nbutane\rsview\report\FC Daily Report.xls", "C:\nbutane\rsview\report\FC Daily Report" & Format(Date - 1, "ddmmyyyy") & ".xls"
End Sub

this would give u the taget file as FC Daily Report08112004.xls

>Target (new filename) : FC Daily Report.xls 07112004.xls
For this

FileCopy "C:\nbutane\rsview\report\FC Daily Report.xls", "C:\nbutane\rsview\report\FC Daily Report.xls" & Format(Date - 1, "ddmmyyyy") & ".xls"
End Sub


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Not really part of your question but you may find formatting the date as yyyymmdd will help you when it comes to sorting the list of files alphabeticallu, they will appear in date order.
ckchew666Author Commented:

Thx for ur code, you are realy good :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.