How To add Hyperlink to all files in a folder


S

Salman Qureshi

I have more than 700 pdf files in a folder.How i hyperlink all files
in one go?


Thanks in advance for help
 
Ad

Advertisements

M

Mike H

Hi,

Try this code. If you have files other than PDF and you dont want those
files use this line

Dir(MyPath & "*.Pdf")
in place of
activefile = Dir(MyPath)

Sub Add_Links()
Dim x As Long
x = 1
Application.DisplayAlerts = False
'Change this to your directory
MyPath = "C:\"
activefile = Dir(MyPath)
Do While activefile <> ""
ActiveSheet.Hyperlinks.Add Anchor:=Cells(x, 1), _
Address:=MyPath & activefile, TextToDisplay:=activefile
activefile = Dir()
x = x + 1
Loop
Application.DisplayAlerts = True
End Sub

Mike
 
Ad

Advertisements

M

Mike H

I meant

use this line
activefile = Dir(MyPath & "*.Pdf")
instead of
activefile = Dir(MyPath)

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top