vivex_pratap
New Member
- Joined
- Aug 24, 2015
- Messages
- 8
Hi,
I have this code which works fine, currently I have to type the folder path in the code, I want to use folder picker in place of that.
Please suggest the changes to be made.
Sub Example1()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("D:\SFA Data\Distribution")
i = 1
'loops through each file in the directory and prints their names and path
For Each objFile In objFolder.Files
Cells(1, 1) = "File Name"
Cells(1, 2) = "File Path"
Cells(1, 3) = "Date Created"
Cells(1, 4) = "Date Modified"
'print file name
Cells(i + 1, 1) = objFile.Name
'print file path
Cells(i + 1, 2) = objFile.Path
Cells(i + 1, 3) = objFile.DateCreated
Cells(i + 1, 4) = objFile.DatelastModified
i = i + 1
Next objFile
End Sub
I have this code which works fine, currently I have to type the folder path in the code, I want to use folder picker in place of that.
Please suggest the changes to be made.
Sub Example1()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("D:\SFA Data\Distribution")
i = 1
'loops through each file in the directory and prints their names and path
For Each objFile In objFolder.Files
Cells(1, 1) = "File Name"
Cells(1, 2) = "File Path"
Cells(1, 3) = "Date Created"
Cells(1, 4) = "Date Modified"
'print file name
Cells(i + 1, 1) = objFile.Name
'print file path
Cells(i + 1, 2) = objFile.Path
Cells(i + 1, 3) = objFile.DateCreated
Cells(i + 1, 4) = objFile.DatelastModified
i = i + 1
Next objFile
End Sub