Sub CreateHyperlinks()
'Creates a Table of Contents (ToC) in active sheet of PDFs in specified folder
Dim myFolder As String
Dim fName As String
Dim myArry As Variant
Dim fPath As String
Dim recCount As Long
'Where are the files located?
myFolder = "C:\My Documents\"
'Make sure that final slash mark was added
If Right(myFolder, 1) <> "\" Then
myFolder = myFolder & "\"
End If
fPath = Dir(myFolder & "*.pdf")
'Create ToC on active sheet, starting in row 1
recCount = 0
Application.ScreenUpdating = False
'Loop through all the files, building Hyperlink formulas
Do Until fPath = ""
recCount = recCount + 1
Cells(recCount, "A").Formula = "=HYPERLINK(""" & myFolder & fPath & """,""" & fPath & """)"
fPath = Dir()
Loop
Application.ScreenUpdating = True
'Brief message to user
MsgBox "Number of files found: " & recCount, vbOKOnly, "Files found"
End Sub