Hello,
Please can some adapt the below code to allow the files to run through sub folders?
Many Thanks
Please can some adapt the below code to allow the files to run through sub folders?
Code:
Sub Example1()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
Sheet2.Activate
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("G:\Shared\Health & Safety\5. Risk Assessments\1. Risk Assessments New")
i = 1
'loops through each file in the directory
For Each objFile In objFolder.Files
'create hyperlink in appropriate cell
ActiveSheet.Hyperlinks.Add Anchor:=ActiveSheet.Cells(i + 1, 2), Address:=objFile.Path, TextToDisplay:=objFile.Name
'add date created to the right
ActiveSheet.Cells(i + 1, 3).Value = objFile.DateLastModified
i = i + 1
Next objFile
End Sub
Many Thanks