zelarra821
Registered User.
- Local time
- Today, 01:37
- Joined
- Jan 14, 2019
- Messages
- 856
Hi guys.
I need your help because I don't see the error.
I'm attaching the Excel spreadsheet I'm working on.
In the "Folder.GetDetailsOf" sheet, I have a table with all the existing and future characteristics of a file, regardless of the file type.
Since I want to extract certain characteristics and I'm tired of trying them one by one, I came up with a solution:
In the "List" sheet, I want it to list all the characteristics in columns for a specific folder and all its subfolders.
I've added the titles so you know the structure I want. That is, starting from row 1 with the titles and going down, all the files should appear. I haven't specified that they should only be MP3s and that it shouldn't include hidden folders, but if you can include them, even better.
My idea is for the titles to be added automatically, not by default. That is, in row 1, take the name of the feature, and then scroll down for each file.
However, when I run the code I used, Excel gets stuck, and I don't see where the error could be coming from.
I mentioned that row 1 should have the name of the feature, but it would also have to have the number, because that's what I'm going to use later to add the genres to all the songs using VBA.
Thanks a lot.
I need your help because I don't see the error.
I'm attaching the Excel spreadsheet I'm working on.
In the "Folder.GetDetailsOf" sheet, I have a table with all the existing and future characteristics of a file, regardless of the file type.
Since I want to extract certain characteristics and I'm tired of trying them one by one, I came up with a solution:
In the "List" sheet, I want it to list all the characteristics in columns for a specific folder and all its subfolders.
I've added the titles so you know the structure I want. That is, starting from row 1 with the titles and going down, all the files should appear. I haven't specified that they should only be MP3s and that it shouldn't include hidden folders, but if you can include them, even better.
My idea is for the titles to be added automatically, not by default. That is, in row 1, take the name of the feature, and then scroll down for each file.
However, when I run the code I used, Excel gets stuck, and I don't see where the error could be coming from.
Code:
Option Explicit
Sub ListarArchivos()
Hoja3.Activate
Hoja3.Cells.Select
Selection.ClearContents
ListFiles "D:\Diego\Mi Música"
End Sub
Sub ListFiles(ByVal path1 As String)
Dim fso As Object
Dim subfolder As Object
Dim file As Object
Dim folder As Object
Dim objShell As Object
Dim objFolder As Object
Dim objFolderItem As Object
Dim Celda As Range
Dim i As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(path1)
Set objShell = CreateObject("Shell.Application")
i = 1
For Each subfolder In folder.SubFolders
ListFiles (subfolder.Path)
Next subfolder
For Each file In folder.Files
Set objFolder = objShell.Namespace(folder.Path)
If (Not objFolder Is Nothing) Then
Set objFolderItem = objFolder.ParseName(file.Name)
If (Not objFolderItem Is Nothing) Then
For Each Celda In Range("Folder.GetDetailsOf[iColum]")
Hoja3.Range("A" & Columns.Count).End(xlToLeft).Offset(1, i) = objFolder.GetDetailsOf(objFolderItem, Celda.Value)
i = i + 1
Next Celda
End If
End If
Next file
Set Celda = Nothing
Set file = Nothing
Set subfolder = Nothing
Set folder = Nothing
Set fso = Nothing
Range("A1").Select
End Sub
I mentioned that row 1 should have the name of the feature, but it would also have to have the number, because that's what I'm going to use later to add the genres to all the songs using VBA.
Thanks a lot.