Renaming Files with Excel VBA

后端 未结 1 499
情歌与酒
情歌与酒 2020-12-03 13:58

Here\'s what I need to do. I have these two columns in an excel sheet. With file names. First column has the current filename and the second column has the names I want the

相关标签:
1条回答
  • 2020-12-03 14:26

    I think you could do something like this, using the Name function to rename the files, however, you will probably need to make sure the 2 columns have the complete file path, i.e. "C:\Temp\ABC.jpg"

    Dim Source As Range
    Dim OldFile As String
    Dim NewFile As String
    
    Set Source = Cells(1, 1).CurrentRegion
    
    For Row = 1 To Source.Rows.Count
        OldFile = ActiveSheet.Cells(Row, 1)
        NewFile = ActiveSheet.Cells(Row, 2)
    
        ' rename files
        Name OldFile As Newfile
    
    Next
    
    0 讨论(0)
提交回复
热议问题