DrallocD,
I used your code taking up some ideas from allen browne's method to insert the file properties in a table. Everything was working just fine until I decided to add file.Duration into the equation. After that I am getting an error message "Error 438(Object doesn't support this property or method)" Any suggestion to improve the code to get the extended properties.
Public Sub listQFiles(startFolder As String, Optional recurse As Boolean = True)
On Error GoTo ErrorHappened
Dim fso, folder, file, subfolder
Dim strSQL2 As String
Dim frname As String
Dim frpath As String
Dim frsize As String
Dim frduration As String
Set fso = CreateObject("Scripting.FileSystemObject")
If LenB(startFolder) = 0 Then Exit Sub
If Right(startFolder, 1) <> "\" Then startFolder = startFolder & "\"
Set folder = fso.GetFolder(startFolder)
For Each file In folder.Files
Debug.Print file.Name, file.Path, file.DateLastModified, file.DateCreated, file.Size, file.Duration
frname = file.Name
frpath = file.Path
frsize = file.Size
frduration = file.Duration
'strSQL2 = "Insert into Files (FName, FPath, FSize) select " & frname & "," & frpath & "," & frsize & ";"
strSQL2 = "Insert into QFiles (FName, FPath, FSize, FDuration) select '" & frname & "','" & frpath & "','" & frsize & "','" & frduration & "';"
CurrentDb.Execute strSQL2
Next
If recurse Then
For Each subfolder In folder.SubFolders
For Each file In subfolder.Files
'listFiles subfolder.Path, recurse
frname = file.Name
frpath = file.Path
frsize = file.Size
frduration = file.Duration
strSQL2 = "Insert into QFiles (FName, FPath, FSize, FDuration) select '" & frname & "','" & frpath & "','" & frsize & "','" & frduration & "';"
CurrentDb.Execute strSQL2
Next
Next
End If
ExitNow:
On Error Resume Next
Set fso = Nothing
Set folder = Nothing
Set file = Nothing
Set subfolder = Nothing
Exit Sub
ErrorHappened:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
Resume ExitNow
End Sub