LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
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




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename Worksheet Tab as File Name Using a Macro Cue Excel Discussion (Misc queries) 10 December 24th 09 06:38 PM
rename excel file name TJ Excel Discussion (Misc queries) 8 June 27th 09 01:56 PM
Batch file rename macro [email protected] Excel Programming 0 March 8th 08 03:41 PM
Rename .txt file with macro markjhunter Excel Programming 3 November 2nd 04 05:50 PM
rename file macro dtroupe Excel Programming 1 December 5th 03 12:50 AM


All times are GMT +1. The time now is 02:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"