View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Rename a .txt file via Excel macro

You seem to be asking for code like this...

OldFN = "G:\My Reports\Transfers\stafflist.txt"
NewFN = Replace(OldFN, "Transfers", Format(Date, _
"mmmm yy"), Compa=vbTextCompare)
NewFN = Replace(NewFN, ".txt", " " & Format(Date, "ddmmyy") & ".txt")
Name OldFN As NewFN

where I have assumed your own code has retrieved the filename and path...
just assign it to the OldFN variable and use the rest of the code I posted
to change it to the format you want and to save it to the new location.

--
Rick (MVP - Excel)


"Tracey" wrote in message
...
Hi All,

I would like to rename and save a .txt file from within an Excel macro. I
don't need to open the file just Save As to another location.

Currently:
G:\My Reports\Transfers\stafflist.txt

Needs to be:
G:\My Reports\December 09\stafflist 041209.txt

Is there some code that will do this for me - thanks in advance :)
--
Tracey @ BrisVegas