ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How To add Hyperlink to all files in a folder (https://www.excelbanter.com/excel-discussion-misc-queries/251499-how-add-hyperlink-all-files-folder.html)

Salman Qureshi

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


Thanks in advance for help

Mike H

How To add Hyperlink to all files in a folder
 
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

"Salman Qureshi" wrote:

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


Thanks in advance for help
.


Mike H

How To add Hyperlink to all files in a folder
 
I meant

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

Mike

"Mike H" wrote:

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

"Salman Qureshi" wrote:

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


Thanks in advance for help
.



All times are GMT +1. The time now is 07:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com