|
Sub 改名()
Dim strFileName$, strPath$, wkb As Workbook
Dim brr, i&, R&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
strPath = ThisWorkbook.Path & "\名单\"
strFileName = Dir(strPath & "*.pdf")
While strFileName <> ""
dic(strFileName) = ""
strFileName = Dir
Wend
R = Cells(Rows.Count, "j").End(xlUp).Row
brr = [a1].Resize(R, 12)
For i = 1 To UBound(brr)
If brr(i, 10) <> brr(i, 11) Then
If dic.exists(brr(i, 11) & ".pdf") Then
dic.Remove brr(i, 11) & ".pdf"
f = "附件" & brr(i, 1) & "、" & brr(i, 10) & "的资料.pdf"
Name strPath & brr(i, 11) & ".pdf" As strPath & f
ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, "y"), Address:=strPath & f, _
TextToDisplay:=f
End If
End If
Next i
Application.ScreenUpdating = True
Beep
End Sub |
|