Auto Hyperlink PDF files
Hi everyone,
I found a VBA code to make pdf auto hyperlink but my problem is I want the filename that will display is data in my excel not the filename of the PDF.
Example:
Column A
aaa1
aaa2
aaa3
the hyperlink you should insert in column a.
here is the code:
Sub AddHyperlink()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("\\server\folder\")
i = 2
'loops through each file in the directory
For Each objFile In objFolder.Files
'select cell
Range(Cells(i + 1, 1), Cells(i + 1, 1)).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
objFile.Path, _
TextToDisplay:=objFile.Name
i = i + 1
Next objFile
End Sub
thank you in advance!
|