How to link to external files from Excel index?

Occasional Visitor

I have created an index using Excel.  How can I create hyperlinks from each entry to the corresponding .pdf document?  


1 Reply


A long time ago, I found the following code for a similar problem on the Internet, maybe you can adapt it:


Private Sub Worksheet_SelectionChange (ByVal Target As Excel.Range)
'The macro is executed when there is a cell in the range
'B1: B99 is highlighted. The range can be adjusted.
 If Target.Column = 2 And Target.Row <100 Then
'The hyperlink in the cell to the left of the selected cell
'is running. This will save the linked PDF file in
'Acrobat Reader opened.
 Target.Offset (0, -1) .Hyperlinks (1) .Follow NewWindow: = False,
AddHistory: = True
'The cell with the search term is assigned to the variable "search".
'It is the cell to the right of the selected cell.
     Set such = Target.Offset (0, 1)
'The length of the search term is assigned to the variable x.
     x = Len (such)
'To solve problems with the flow of the macro and the actions that
'to avoid being triggered by SendKeys, the
'Macro sequence interrupted for 2 seconds.
     Application.Wait (Now + TimeValue ("0:00:02"))
'The key sequence CTRL-F is sent (as if
'pressed the buttons manually). This causes Acrobat
'Reader the search function is called. The cursor is stationary
'in the field in which the search term must be entered.
     Application.SendKeys "^ f"
'In the loop, all the letters des
'in "search" text (= search term ") sent.
'The process is stopped at 1 second each time.
'Application.SendKeys Mid (such, i, 1) means that the i-th
'The letter of the search term "should be typed in".
     For i = 1 To x
     Application.Wait (Now + TimeValue ("0:00:01"))
     Application.SendKeys Mid (such, i, 1)
     Next i
'Finally, the key combination ALT-S is sent, which is saved in
'Acrobat Reader starts the search process.
     Application.SendKeys "% s"
 End If
 End Sub 



I would be happy to know if I could help.


I know I don't know anything (Socrates)

* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.