批量获取当前文件夹下pdf文件名并去掉扩展名

Sub 批量获取当前文件夹下文件名并去掉扩展名()
  Dim p$, f$, n%
  Set Dic = CreateObject("Scripting.Dictionary")
  p = ThisWorkbook.Path & "\"
  f = Dir(p & "*.pdf")
  n = 1
  Do While Len(f)
​    If f <> ThisWorkbook.Name Then
​      Dic(f) = ""
​    End If
    Range("a" & n).Value = Left(f, Len(f) - 4)
    n = n + 1
    f = Dir
  Loop
End Sub

你可能感兴趣的:(批量获取当前文件夹下pdf文件名并去掉扩展名)