Thread: Rename Files
View Single Post
 
Old 05-11-2012, 08:15 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,365
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote