Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Renaming files in a directory

How do I rename the files in a directory? I have many reports in directory I
can loop through each file but how do i rename it? I have an input box to
assign a NewFileName. I want to keep the date suffix and change the first
part of the filename. This jams in the last line attempts. Please help. I
feel like i'm shooting inthe dark now.

If Right(myName, 3) = "xls" Then
OldFileName = myPath & myName
NameDate = Right(myName, 12)
NewFileName = (myPath & NewName & " " & NameDate)
Workbooks(OldFileName).SaveAs (NewFileName)
'Workbooks(OldFileName).Name = (NewFileName)

TIA
Candyman
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Renaming files in a directory

As long as you're not trying to rename the file that you are currently
working on you can use the Name function.

Name OldFileName as NewFileName

This way you don't have to use "SaveAs"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Renaming files in a directory

Thats it! YES!!!
Thanks :)

"JGeniti" wrote:

As long as you're not trying to rename the file that you are currently
working on you can use the Name function.

Name OldFileName as NewFileName

This way you don't have to use "SaveAs"


Reply
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
Maintain cell links when renaming directory containing multiple f Excel52 Excel Worksheet Functions 0 April 28th 05 10:54 PM
Renaming adding and deleting directory alanford Excel Programming 2 February 16th 05 11:08 AM
Renaming Files mudraker[_304_] Excel Programming 2 August 13th 04 12:04 AM
Renaming all files in a directory Jan Kronsell[_3_] Excel Programming 4 February 19th 04 12:33 PM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM


All times are GMT +1. The time now is 11:15 PM.

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

About Us

"It's about Microsoft Excel"