I have the following code that creates hyperlinks from all pdfs contained in a folder and listed in column N.
Sub extractfiles_hyperlink()
Dim xFSO As Object
Dim xFolder As Object
Dim xFile As Object
Dim xFiDialog As FileDialog
Dim xPath As String
Dim i As Integer
Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker)
If xFiDialog.Show = -1 Then
xPath = xFiDialog.SelectedItems(1)
End If
Set xFiDialog = Nothing
If xPath = "" Then Exit Sub
Set xFSO = CreateObject("Scripting.FileSystemObject")
Set xFolder = xFSO.GetFolder(xPath)
For Each xFile In xFolder.Files
i = i + 1
ActiveSheet.Hyperlinks.Add Cells(i + 5, 14), xFile.Path, , , xFile.Name
Next
End Sub
Problem:
I want either sort those hyperlinks and match their name with column A ( as you can see from the image, they don't match) or create a hyperlink directly to column A and, if the file is not in the folder, print a message saying " missing - send a reminder to add to folder "(planning to create code to send an automatic email to the responsible person but for now just this :D )
Thank you in advance for your help on my post
Sub extractfiles_hyperlink()
Dim xFSO As Object
Dim xFolder As Object
Dim xFile As Object
Dim xFiDialog As FileDialog
Dim xPath As String
Dim i As Integer
Set xFiDialog = Application.FileDialog(msoFileDialogFolderPicker)
If xFiDialog.Show = -1 Then
xPath = xFiDialog.SelectedItems(1)
End If
Set xFiDialog = Nothing
If xPath = "" Then Exit Sub
Set xFSO = CreateObject("Scripting.FileSystemObject")
Set xFolder = xFSO.GetFolder(xPath)
For Each xFile In xFolder.Files
i = i + 1
ActiveSheet.Hyperlinks.Add Cells(i + 5, 14), xFile.Path, , , xFile.Name
Next
End Sub
Problem:
I want either sort those hyperlinks and match their name with column A ( as you can see from the image, they don't match) or create a hyperlink directly to column A and, if the file is not in the folder, print a message saying " missing - send a reminder to add to folder "(planning to create code to send an automatic email to the responsible person but for now just this :D )
Thank you in advance for your help on my post