Excel VBA 对文件 重命名

Sub rename()
With Application.ActiveSheet
basePath = Application.ActiveWorkbook.Path
i = 1
Do While (.Cells(i, 1) <> "")
strFileName = basePath & "\" & .Cells(i, 1) & ".pdf"
If Dir(strFileName, 16) <> Empty Then
      Name strFileName As basePath & "\" & .Cells(i, 2) & ".pdf"
    End If
i = i + 1
Loop
End With
End Sub

你可能感兴趣的:(Excel,Vba)