Thread: Rename Files
View Single Post
 
Old 05-14-2012, 02:15 AM
gsrikanth gsrikanth is offline Windows XP Office XP
Competent Performer
 
Join Date: Dec 2011
Posts: 133
gsrikanth is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Hi,

You can use code like the following. I've assumed the names are in your workbook. If they're not, you can modify the code to suit - the basic principles are the same. Note that the Filepath must end with a "\"
Code:
Sub RenameFiles()
Dim i As Long, Strpath As String
Strpath = "Filepath"
With ActiveSheet
  On Error Resume Next
  For i = 1 To 12
    If Dir(Strpath & .Cells(i, 2).Value, vbNormal) <> "" Then
      Name Strpath & .Cells(i, 2).Value As Strpath & .Cells(i, 1).Value & .Cells(i, 2).Value
    End If
  Next
End With
End Sub
PS: Please don't post Excel vba questions in the Word vba forum.
in Filepath place in kept my path "\\geodb-1\f\villages\"
i have folder that
excel i kept attachment

using above code no replace occur
Attached Files
File Type: xlsx Book20.xlsx (10.6 KB, 10 views)
Reply With Quote