Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Changing File Name

Hi,

Suppose i have a Folder August 07
Inside there are 50 folders of Different Employees
Under Each folder i have one Excel File with the name of "Format for
the 1st Aug to 10 Aug"

Now what i want is to change the name of the File from "Format for the
1st Aug to 10 Aug" to "Current Time Sheet For 1st Aug to 10th Aug"

How can i do that....

Thanks

Regards
Akash

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Changing File Name

Dim FSO As Object

Sub Folders()
Dim i As Long
Dim sFolder As String

Set FSO = CreateObject("Scripting.FileSystemObject")
SelectFiles "C:\test"

End Sub

'-----------------------------------------------------------------------
Sub SelectFiles(Optional sPath As String)
'-----------------------------------------------------------------------
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object

Const LookFor As String = "Format for the"
Const ChangeTo As String = "Current Time Sheet For"

Set Folder = FSO.GetFolder(sPath)

Set Files = Folder.Files
For Each file In Files
If file.Type Like "*Excel*" Then
If Left$(file.Name, 14) = LookFor Then
Name file.Path As Replace(file.Path, LookFor, ChangeTo)
End If
End If
Next file

For Each fldr In Folder.Subfolders
SelectFiles fldr.Path
Next

End Sub




--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Akash" wrote in message
oups.com...
Hi,

Suppose i have a Folder August 07
Inside there are 50 folders of Different Employees
Under Each folder i have one Excel File with the name of "Format for
the 1st Aug to 10 Aug"

Now what i want is to change the name of the File from "Format for the
1st Aug to 10 Aug" to "Current Time Sheet For 1st Aug to 10th Aug"

How can i do that....

Thanks

Regards
Akash



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Changing File Name

On Aug 16, 2:30 pm, "Bob Phillips" wrote:
Dim FSO As Object

Sub Folders()
Dim i As Long
Dim sFolder As String

Set FSO = CreateObject("Scripting.FileSystemObject")
SelectFiles "C:\test"

End Sub

'-----------------------------------------------------------------------
Sub SelectFiles(Optional sPath As String)
'-----------------------------------------------------------------------
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object

Const LookFor As String = "Format for the"
Const ChangeTo As String = "Current Time Sheet For"

Set Folder = FSO.GetFolder(sPath)

Set Files = Folder.Files
For Each file In Files
If file.Type Like "*Excel*" Then
If Left$(file.Name, 14) = LookFor Then
Name file.Path As Replace(file.Path, LookFor, ChangeTo)
End If
End If
Next file

For Each fldr In Folder.Subfolders
SelectFiles fldr.Path
Next

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Akash" wrote in message

oups.com...

Hi,


Suppose i have a Folder August 07
Inside there are 50 folders of Different Employees
Under Each folder i have one Excel File with the name of "Format for
the 1st Aug to 10 Aug"


Now what i want is to change the name of the File from "Format for the
1st Aug to 10 Aug" to "Current Time Sheet For 1st Aug to 10th Aug"


How can i do that....


Thanks


Regards
Akash


Its not working....

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Changing File Name

Well that is a very illuminating response.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Akash" wrote in message
ups.com...
On Aug 16, 2:30 pm, "Bob Phillips" wrote:
Dim FSO As Object

Sub Folders()
Dim i As Long
Dim sFolder As String

Set FSO = CreateObject("Scripting.FileSystemObject")
SelectFiles "C:\test"

End Sub

'-----------------------------------------------------------------------
Sub SelectFiles(Optional sPath As String)
'-----------------------------------------------------------------------
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object

Const LookFor As String = "Format for the"
Const ChangeTo As String = "Current Time Sheet For"

Set Folder = FSO.GetFolder(sPath)

Set Files = Folder.Files
For Each file In Files
If file.Type Like "*Excel*" Then
If Left$(file.Name, 14) = LookFor Then
Name file.Path As Replace(file.Path, LookFor, ChangeTo)
End If
End If
Next file

For Each fldr In Folder.Subfolders
SelectFiles fldr.Path
Next

End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Akash" wrote in message

oups.com...

Hi,


Suppose i have a Folder August 07
Inside there are 50 folders of Different Employees
Under Each folder i have one Excel File with the name of "Format for
the 1st Aug to 10 Aug"


Now what i want is to change the name of the File from "Format for the
1st Aug to 10 Aug" to "Current Time Sheet For 1st Aug to 10th Aug"


How can i do that....


Thanks


Regards
Akash


Its not working....



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
update the hyperlink in file after changing the file name Bel71 Excel Worksheet Functions 3 May 11th 10 03:47 PM
delete info from source file w/out changing the destination file TB New Users to Excel 0 May 26th 08 06:26 PM
Save as new file without changing existing file mcphc Excel Programming 5 February 15th 07 04:00 PM
Open Test file with VBA with a changing file number Michael from Austin Excel Programming 4 October 14th 05 03:18 PM
Open delimited text file to excel without changing data in that file zohanc Excel Programming 1 October 3rd 03 01:06 AM


All times are GMT +1. The time now is 03:40 PM.

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"