Hello all,

Back in 2008, with the help of some of the members here, we were able to create a macro that would hyperlink all the pdf files in a specified folder and display them in descending order in the excel spreadsheet as their file names. I believe it was Excel 2003 that I was using at the time. I am now looking to use this macro for Excel 2010 and am running into Run-time error '438'.

Is anyone able to suggest a solution for this? If so, my company would greatly appreciate it as it was an incredibly useful tool back when it was working properly.

Thank you very much and I look forward to your responses/suggestions. I've attached the old code below.

Paul B

Sub CREATEPDFDIRECTORY()
Dim path As String
Dim f As Integer
path = "filepath"
f = 1
 
With Application.FileSearch
.LookIn = path
.FileType = msoFileTypeAllFiles
.Execute
For i = 1 To .FoundFiles.Count
If UCase(Right(.FoundFiles(i), 3)) = "PDF" Then
Range("A" & f).Value = .FoundFiles(i)
ActiveSheet.Hyperlinks.Add Anchor:=Range("A" & f), _
Address:=.FoundFiles(i), TextToDisplay:=Split(Dir(.FoundFiles(i)), ".")(0)

 

f = f + 1
End If
Next i
End With
 
End Sub