Morshed_Dhaka
New Member
- Joined
- Dec 16, 2016
- Messages
- 42
Hello Everyone,
i am struggling with the below code with 2 specific requirments. Here is my code & requirments :
1. Instead of writing down the folder name here "Set objFolder = objFSO.GetFolder("C:\Users\UserName\FolderName")" , is it possible to use FolderPicker option so that it will visually guide the user to select the folder to collect all the files name & files path details of that selected folder????
2. By using the below code, i am getting file name in a excel file with extension like .xlx / .pdf / .jpg. Is it possible by modifying the below code, i will only get the file name??? i don't want extension name.
Below is my code
Sub FileDetails()
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("C:\Users\UserName\FolderName")
i = 1
'loops through each file in the directory and prints their names and path
For Each objFile In objFolder.Files
'print file name
Cells(i + 1, 1) = objFile.Name
'print file path
Cells(i + 1, 2) = objFile.Path
i = i + 1
Next objFile
End Sub
will be really gratefull if anyone able to help me for this simple problem. Thanks in advance
i am struggling with the below code with 2 specific requirments. Here is my code & requirments :
1. Instead of writing down the folder name here "Set objFolder = objFSO.GetFolder("C:\Users\UserName\FolderName")" , is it possible to use FolderPicker option so that it will visually guide the user to select the folder to collect all the files name & files path details of that selected folder????
2. By using the below code, i am getting file name in a excel file with extension like .xlx / .pdf / .jpg. Is it possible by modifying the below code, i will only get the file name??? i don't want extension name.
Below is my code
Sub FileDetails()
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("C:\Users\UserName\FolderName")
i = 1
'loops through each file in the directory and prints their names and path
For Each objFile In objFolder.Files
'print file name
Cells(i + 1, 1) = objFile.Name
'print file path
Cells(i + 1, 2) = objFile.Path
i = i + 1
Next objFile
End Sub
will be really gratefull if anyone able to help me for this simple problem. Thanks in advance