Hi all. I am currently looking for a VBA which can get the full path of the selected file in the specific column.
I found a VBA code which can help to get all the files from a selected folder. However, I want to breakdown into the selected files.
Many thanks for all experts
I found a VBA code which can help to get all the files from a selected folder. However, I want to breakdown into the selected files.
VBA Code:
Option Explicit
Sub listAllFiles()
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("D:\Testing\20200626")
Call GetFileDetails(objFolder)
End Sub
Function GetFileDetails(objFolder As Scripting.Folder)
Dim objFile As Scripting.file
Dim nextRow As Long
Dim objSubFolder As Scripting.Folder
nextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
For Each objFile In objFolder.Files
If objFile Like "*.xlsx*" Then '(can delete if u want to list all type of files)
Cells(nextRow, 1) = objFile.Name
Cells(nextRow, 2) = objFile.Path
Cells(nextRow, 3) = objFile.Size
Cells(nextRow, 4) = objFile.Type
Cells(nextRow, 5) = objFile.DateCreated
Cells(nextRow, 6) = objFile.DateLastModified
nextRow = nextRow + 1
End If '(can delete if u want to list all type of files)
Next
For Each objSubFolder In objFolder.SubFolders
Call GetFileDetails(objSubFolder)
Next
End Function
Many thanks for all experts