Option Explicit
Sub addHyperlinks()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
Dim dataSheet As Worksheet
Set dataSheet = ورقة1
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("C:\Users\Khaled\Desktop\ارشيف")
i = 1
'Loop through each file in the folder
For Each objFile In objFolder.Files
dataSheet.Hyperlinks.Add Anchor:=Cells(i, 5), Address:=objFile.Path, TextToDisplay:=objFile.Name, ScreenTip:=objFile.Path
i = i + 1
Next objFile
End Sub
جرب هذا الكود وهو منقول من موقع اجنبي